pgsql: Optionally prefetch referenced data in recovery. - Mailing list pgsql-committers

From Thomas Munro
Subject pgsql: Optionally prefetch referenced data in recovery.
Date
Msg-id E1lUSkg-0007xN-Cx@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Optionally prefetch referenced data in recovery.

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.

Reviewed-by: Alvaro Herrera <alvherre@2ndquadrant.com> (parts)
Reviewed-by: Andres Freund <andres@anarazel.de> (parts)
Reviewed-by: Tomas Vondra <tomas.vondra@2ndquadrant.com> (parts)
Tested-by: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Tested-by: Jakub Wartak <Jakub.Wartak@tomtom.com>
Tested-by: Dmitry Dolgov <9erthalion6@gmail.com>
Tested-by: Sait Talha Nisanci <Sait.Nisanci@microsoft.com>
Discussion: https://postgr.es/m/CA%2BhUKGJ4VJN8ttxScUFM8dOKX0BrBiboo5uz1cq%3DAovOddfHpA%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/1d257577e08d3e598011d6850fd1025858de8c8c

Modified Files
--------------
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(-)


pgsql-committers by date:

Previous
From: Julien Rouhaud
Date:
Subject: Re: pgsql: Move pg_stat_statements query jumbling to core.
Next
From: David Rowley
Date:
Subject: pgsql: Speedup ScalarArrayOpExpr evaluation