postgres-github.git / summary / log / commit / refs

commit    a9ee66881744d67193b56964b8398e5f83130956
Author:   Andres Freund <andres@anarazel.de>
Date:     Sun Apr 05 04:43:54 2026 +0000

    aio: io_uring: Trigger async processing for large IOs
    
    io_method=io_uring has a heuristic to trigger asynchronous processing of IOs
    once the IO depth is a bit larger. That heuristic is important when doing
    buffered IO from the kernel page cache, to allow parallelizing of the memory
    copy, as otherwise io_method=io_uring would be a lot slower than
    io_method=worker in that case.
    
    An upcoming commit will make read_stream.c only increase the read-ahead
    distance if we needed to wait for IO to complete. If to-be-read data is in the
    kernel page cache, io_uring will synchronously execute IO, unless the IO is
    flagged as async.  Therefore the aforementioned change in read_stream.c
    heuristic would lead to a substantial performance regression with io_uring
    when data is in the page cache, as we would never reach a deep enough queue to
    actually trigger the existing heuristic.
    
    Parallelizing the copy from the page cache is mainly important when doing a
    lot of IO, which commonly is only possible when doing largely sequential IO.
    
    The reason we don't just mark all io_uring IOs as asynchronous is that the
    dispatch to a kernel thread has overhead. This overhead is mostly noticeable
    with small random IOs with a low queue depth, as in that case the gain from
    parallelizing the memory copy is small and the latency cost high.
    
    The facts from the two prior paragraphs show a way out: Use the size of the IO
    in addition to the depth of the queue to trigger asynchronous processing.
    
    One might think that just using the IO size might be enough, but
    experimentation has shown that not to be the case - with deep look-ahead
    distances being able to parallelize the memory copy is important even with
    smaller IOs.
    
    Reviewed-by: Melanie Plageman <melanieplageman@gmail.com>
    Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>
    Discussion: https://postgr.es/m/f3xxfrkafjxpyqxywcxricxgyizjirfceychyxsgn7bwjp5eda@kwbduhy7tfmu
    Discussion: https://postgr.es/m/CA+hUKGL2PhFyDoqrHefqasOnaXhSg48t1phs3VM8BAdrZqKZkw@mail.gmail.com

[parent: 2849fe4c9785]