Re: AIO v2.5

From: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Noah Misch <noah(at)leadboat(dot)com>, Antonin Houska <ah(at)cybertec(dot)at>, pgsql-hackers(at)postgresql(dot)org, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Robert Haas <robertmhaas(at)gmail(dot)com>, Jakub Wartak <jakub(dot)wartak(at)enterprisedb(dot)com>, Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Subject: Re: AIO v2.5
Date: 2025-03-25 00:07:49
Message-ID: CA+hUKGJPTf3pJXVLyQ_aEFFTRGbaJgANG2wpa94L0htEdDC4AQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Mar 25, 2025 at 11:55 AM Andres Freund <andres(at)anarazel(dot)de> wrote:
> If a callback may sometimes need to block, it can still opt into
> READ_STREAM_USE_BATCHING, by submitting all staged IO before blocking.
>
> The hardest part is to explain the flag. Here's my current attempt:
>
> /* ---
> * Opt-in to using AIO batchmode.
> *
> * Submitting IO in larger batches can be more efficient than doing so
> * one-by-one, particularly for many small reads. It does, however, require
> * the ReadStreamBlockNumberCB callback to abide by the restrictions of AIO
> * batching (c.f. pgaio_enter_batchmode()). Basically, the callback may not:
> * a) block without first calling pgaio_submit_staged(), unless a
> * to-be-waited-on lock cannot be part of a deadlock, e.g. because it is
> * never acquired in a nested fashion
> * b) directly or indirectly start another batch pgaio_enter_batchmode()
> *
> * As this requires care and is nontrivial in some cases, batching is only
> * used with explicit opt-in.
> * ---
> */
> #define READ_STREAM_USE_BATCHING 0x08

+1

I wonder if something more like READ_STREAM_CALLBACK_BATCHMODE_AWARE
would be better, to highlight that you are making a declaration about
a property of your callback, not just turning on an independent
go-fast feature... I fished those words out of the main (?)
description of this topic atop pgaio_enter_batchmode(). Just a
thought, IDK.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2025-03-25 00:18:51 Re: AIO v2.5
Previous Message Masahiko Sawada 2025-03-24 23:58:51 Re: Parallel heap vacuum