Provide vectored variant of ReadBuffer().
authorThomas Munro
Tue, 2 Apr 2024 11:03:08 +0000 (00:03 +1300)
committerThomas Munro
Tue, 2 Apr 2024 11:23:20 +0000 (00:23 +1300)
commit210622c60e1a9db2e2730140b8106ab57d259d15
tree9c8de4c53e6cd36fd48ac078d45037e5e8623e23
parent13b3b62746ec8bd9c8e3f0bc23862f1172996333
Provide vectored variant of ReadBuffer().

Break ReadBuffer() up into two steps.  StartReadBuffers() and
WaitReadBuffers() give us two main advantages:

1.  Multiple consecutive blocks can be read with one system call.
2.  Advice (hints of future reads) can optionally be issued to the
kernel ahead of time.

The traditional ReadBuffer() function is now implemented in terms of
those functions, to avoid duplication.

A new GUC io_combine_limit is defined, and the functions for limiting
per-backend pin counts are made into public APIs.  Those are provided
for use by callers of StartReadBuffers(), when deciding how many buffers
to read at once.  The following commit will add a higher level mechanism
for doing that automatically with a practical interface.

With some more infrastructure in later work, StartReadBuffers() could
be extended to start real asynchronous I/O instead of just issuing
advice and leaving WaitReadBuffers() to do the work synchronously.

Author: Thomas Munro 
Author: Andres Freund  (some optimization tweaks)
Reviewed-by: Melanie Plageman
Reviewed-by: Heikki Linnakangas
Reviewed-by: Nazir Bilal Yavuz
Reviewed-by: Dilip Kumar
Reviewed-by: Andres Freund
Tested-by: Tomas Vondra
Discussion: https://postgr.es/m/CA+hUKGJkOiOCa+mag4BF+zHo7qo=o9CFheB8=g6uT5TUm2gkvA@mail.gmail.com
doc/src/sgml/config.sgml
src/backend/storage/buffer/bufmgr.c
src/backend/storage/buffer/localbuf.c
src/backend/utils/misc/guc_tables.c
src/backend/utils/misc/postgresql.conf.sample
src/include/storage/bufmgr.h
src/tools/pgindent/typedefs.list