diff options
author | Thomas Munro <tmunro@postgresql.org> | 2023-04-08 11:04:49 +1200 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2023-04-08 16:35:07 +1200 |
commit | d4e71df6d757fd21c363164a3a4d3b5681462662 (patch) | |
tree | 27db4af292830160ecfe4789645f87d0e5a1daea /src/include | |
parent | faeedbcefd40bfdf314e048c425b6d9208896d90 (diff) | |
download | postgresql-d4e71df6d757fd21c363164a3a4d3b5681462662.tar.gz |
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.munro@gmail.com>
Author: Andres Freund <andres@anarazel.de>
Author: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Reviewed-by: Justin Pryzby <pryzby@telsasoft.com>
Reviewed-by: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Discussion: https://postgr.es/m/CA%2BhUKGK1X532hYqJ_MzFWt0n1zt8trz980D79WbjwnT-yYLZpg%40mail.gmail.com
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/storage/fd.h | 7 | ||||
-rw-r--r-- | src/include/storage/smgr.h | 1 | ||||
-rw-r--r-- | src/include/utils/guc_hooks.h | 2 |
3 files changed, 10 insertions, 0 deletions
diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h index faac4914fe..6791a406fc 100644 --- a/src/include/storage/fd.h +++ b/src/include/storage/fd.h @@ -44,6 +44,7 @@ #define FD_H #include <dirent.h> +#include <fcntl.h> typedef enum RecoveryInitSyncMethod { @@ -54,10 +55,16 @@ typedef enum RecoveryInitSyncMethod typedef int File; +#define IO_DIRECT_DATA 0x01 +#define IO_DIRECT_WAL 0x02 +#define IO_DIRECT_WAL_INIT 0x04 + + /* GUC parameter */ extern PGDLLIMPORT int max_files_per_process; extern PGDLLIMPORT bool data_sync_retry; extern PGDLLIMPORT int recovery_init_sync_method; +extern PGDLLIMPORT int io_direct_flags; /* * This is private to fd.c, but exported for save/restore_backend_variables() diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h index a9a179aaba..17fba6f91a 100644 --- a/src/include/storage/smgr.h +++ b/src/include/storage/smgr.h @@ -17,6 +17,7 @@ #include "lib/ilist.h" #include "storage/block.h" #include "storage/relfilelocator.h" +#include "utils/guc.h" /* * smgr.c maintains a table of SMgrRelation objects, which are essentially diff --git a/src/include/utils/guc_hooks.h b/src/include/utils/guc_hooks.h index f722fb250a..a82a85c940 100644 --- a/src/include/utils/guc_hooks.h +++ b/src/include/utils/guc_hooks.h @@ -156,5 +156,7 @@ extern bool check_wal_consistency_checking(char **newval, void **extra, GucSource source); extern void assign_wal_consistency_checking(const char *newval, void *extra); extern void assign_xlog_sync_method(int new_sync_method, void *extra); +extern bool check_io_direct(char **newval, void **extra, GucSource source); +extern void assign_io_direct(const char *newval, void *extra); #endif /* GUC_HOOKS_H */ |