Optionally prefetch referenced data in recovery

Enterprise / PostgreSQL - Thomas Munro [postgresql.org] - 8 April 2021 11:20 UTC

Introduce a new GUC recovery_prefetch, disabled by default. When enabled, look ahead in the WAL and try to initiate asynchronous reading of referenced data blocks that are not yet cached in our buffer pool. For now, this is done with posix_fadvise(), which has several caveats. Better mechanisms will follow in later work on the I/O subsystem.

The GUC maintenance_io_concurrency is used to limit the number of concurrent I/Os we allow ourselves to initiate, based on pessimistic heuristics used to infer that I/Os have begun and completed.

The GUC wal_decode_buffer_size is used to limit the maximum distance we are prepared to read ahead in the WAL to find uncached blocks.

1d257577e0 Optionally prefetch referenced data in recovery.
doc/src/sgml/config.sgml | 83 +++
doc/src/sgml/monitoring.sgml | 86 ++-
doc/src/sgml/wal.sgml | 17 +
src/backend/access/transam/Makefile | 1 +
src/backend/access/transam/xlog.c | 50 +-
src/backend/access/transam/xlogprefetch.c | 922 ++++++++++++++++++++++++++
src/backend/access/transam/xlogreader.c | 13 +
src/backend/access/transam/xlogutils.c | 23 +-
src/backend/catalog/system_views.sql | 14 +
src/backend/postmaster/pgstat.c | 103 ++-
src/backend/storage/freespace/freespace.c | 3 +-
src/backend/storage/ipc/ipci.c | 3 +
src/backend/utils/misc/guc.c | 51 +-
src/backend/utils/misc/postgresql.conf.sample | 6 +
src/include/access/xlog.h | 1 +
src/include/access/xlogprefetch.h | 82 +++
src/include/access/xlogreader.h | 7 +
src/include/access/xlogutils.h | 3 +-
src/include/catalog/pg_proc.dat | 8 +
src/include/pgstat.h | 26 +
src/include/utils/guc.h | 4 +
src/test/regress/expected/rules.out | 11 +
src/tools/pgindent/typedefs.list | 4 +
23 files changed, 1502 insertions(+), 19 deletions(-)

Upstream: git.postgresql.org


  • Share