pgsql: Add io_direct setting (developer-only).

From: Thomas Munro <tmunro(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Add io_direct setting (developer-only).
Date: 2023-04-08 04:35:13
Message-ID: E1pl0IC-001z11-2Z@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add io_direct setting (developer-only).

Provide a way to ask the kernel to use O_DIRECT (or local equivalent)
where available for data and WAL files, to avoid or minimize kernel
caching. This hurts performance currently and is not intended for end
users yet. Later proposed work would introduce our own I/O clustering,
read-ahead, etc to replace the facilities the kernel disables with this
option.

The only user-visible change, if the developer-only GUC is not used, is
that this commit also removes the obscure logic that would activate
O_DIRECT for the WAL when wal_sync_method=open_[data]sync and
wal_level=minimal (which also requires max_wal_senders=0). Those are
non-default and unlikely settings, and this behavior wasn't (correctly)
documented. The same effect can be achieved with io_direct=wal.

Author: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Author: Andres Freund <andres(at)anarazel(dot)de>
Author: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Reviewed-by: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Reviewed-by: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Discussion: https://postgr.es/m/CA%2BhUKGK1X532hYqJ_MzFWt0n1zt8trz980D79WbjwnT-yYLZpg%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d4e71df6d757fd21c363164a3a4d3b5681462662

Modified Files
--------------
doc/src/sgml/config.sgml | 33 ++++++++-
src/backend/access/transam/xlog.c | 37 +++++-----
src/backend/access/transam/xlogprefetcher.c | 2 +-
src/backend/storage/buffer/bufmgr.c | 16 +++--
src/backend/storage/buffer/localbuf.c | 7 +-
src/backend/storage/file/fd.c | 98 +++++++++++++++++++++++++++
src/backend/storage/smgr/md.c | 24 +++++--
src/backend/storage/smgr/smgr.c | 1 +
src/backend/utils/misc/guc_tables.c | 12 ++++
src/include/storage/fd.h | 7 ++
src/include/storage/smgr.h | 1 +
src/include/utils/guc_hooks.h | 2 +
src/test/modules/test_misc/meson.build | 1 +
src/test/modules/test_misc/t/004_io_direct.pl | 57 ++++++++++++++++
14 files changed, 263 insertions(+), 35 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2023-04-08 05:08:10 pgsql: Replace replication slot's invalidated_at LSN with an enum
Previous Message Amit Kapila 2023-04-08 04:24:00 pgsql: Doc: Fix the datatype of the newly added SUBSCRIPTION options.