pgsql: Simplify distance heuristics in read_stream.c. - Mailing list pgsql-committers

From Thomas Munro
Subject pgsql: Simplify distance heuristics in read_stream.c.
Date
Msg-id E1ttRzF-002bZv-1d@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Simplify distance heuristics in read_stream.c.

Make the distance control heuristics simpler and more aggressive in
preparation for asynchronous I/O.

The v17 version of read_stream.c made a conservative choice to limit the
look-ahead distance when streaming sequential blocks, because it
couldn't benefit very much from looking ahead further yet.  It had a
three-behavior model where only random I/O would rapidly increase the
look-ahead distance, to support read-ahead advice.  Sequential I/O would
move it towards the io_combine_limit setting, just enough to build one
full-sized synchronous I/O at a time, and then expect kernel read-ahead
to avoid I/O stalls.

That already left I/O performance on the table with advice-based I/O
concurrency, since sequential blocks could be followed by random jumps,
eg with the proposed streaming Bitmap Heap Scan patch.

It is time to delete the cautious middle option and adjust the distance
based on recent I/O needs only, since asynchronous reads will need to be
started ahead of time whether random or sequential.  It is still limited
by io_combine_limit, *_io_concurrency, buffer availability and
strategy ring size, as before.

Reviewed-by: Andres Freund <andres@anarazel.de> (earlier version)
Tested-by: Melanie Plageman <melanieplageman@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKGK_%3D4CVmMHvsHjOVrK6t4F%3DLBpFzsrr3R%2BaJYN8kcTfWg%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/799959dc7cf0e2462601bea8d07b6edec3fa0c4f

Modified Files
--------------
src/backend/storage/aio/read_stream.c | 68 +++++++++--------------------------
1 file changed, 16 insertions(+), 52 deletions(-)


pgsql-committers by date:

Previous
From: Thomas Munro
Date:
Subject: pgsql: Improve read_stream.c advice for dense streams.
Next
From: Melanie Plageman
Date:
Subject: pgsql: Separate TBM[Shared|Private]Iterator and TBMIterateResult