diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/access/transam/xlog.c | 2 | ||||
-rw-r--r-- | src/backend/utils/misc/guc.c | 8 | ||||
-rw-r--r-- | src/backend/utils/misc/postgresql.conf.sample | 10 | ||||
-rw-r--r-- | src/bin/initdb/initdb.c | 25 | ||||
-rw-r--r-- | src/include/pg_config_manual.h | 18 | ||||
-rw-r--r-- | src/include/storage/bufmgr.h | 11 |
6 files changed, 49 insertions, 25 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index ce4f1fc2989..084401d2f23 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -2759,7 +2759,7 @@ XLogFlush(XLogRecPtr record) * This routine is invoked periodically by the background walwriter process. * * Returns TRUE if there was any work to do, even if we skipped flushing due - * to wal_writer_delay/wal_flush_after. + * to wal_writer_delay/wal_writer_flush_after. */ bool XLogBackgroundFlush(void) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index da74f00ab24..28ebcb6f3fa 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -2281,7 +2281,6 @@ static struct config_int ConfigureNamesInt[] = GUC_UNIT_BLOCKS }, &checkpoint_flush_after, - /* see bufmgr.h: OS dependent default */ DEFAULT_CHECKPOINT_FLUSH_AFTER, 0, WRITEBACK_MAX_PENDING_FLUSHES, NULL, NULL, NULL }, @@ -2310,12 +2309,12 @@ static struct config_int ConfigureNamesInt[] = { {"wal_writer_flush_after", PGC_SIGHUP, WAL_SETTINGS, - gettext_noop("Amount of WAL written out by WAL writer triggering a flush."), + gettext_noop("Amount of WAL written out by WAL writer that triggers a flush."), NULL, GUC_UNIT_XBLOCKS }, &WalWriterFlushAfter, - 128, 0, INT_MAX, + (1024*1024) / XLOG_BLCKSZ, 0, INT_MAX, NULL, NULL, NULL }, @@ -2439,7 +2438,6 @@ static struct config_int ConfigureNamesInt[] = GUC_UNIT_BLOCKS }, &bgwriter_flush_after, - /* see bufmgr.h: OS dependent default */ DEFAULT_BGWRITER_FLUSH_AFTER, 0, WRITEBACK_MAX_PENDING_FLUSHES, NULL, NULL, NULL }, @@ -2467,7 +2465,7 @@ static struct config_int ConfigureNamesInt[] = GUC_UNIT_BLOCKS }, &backend_flush_after, - 0, 0, WRITEBACK_MAX_PENDING_FLUSHES, + DEFAULT_BACKEND_FLUSH_AFTER, 0, WRITEBACK_MAX_PENDING_FLUSHES, NULL, NULL, NULL }, diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 7c2daa54bc8..0df15380a9a 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -156,8 +156,7 @@ #bgwriter_delay = 200ms # 10-10000ms between rounds #bgwriter_lru_maxpages = 100 # 0-1000 max buffers written/round #bgwriter_lru_multiplier = 2.0 # 0-10.0 multiplier on buffers scanned/round -#bgwriter_flush_after = 0 # 0 disables, - # default is 512kB on linux, 0 otherwise +#bgwriter_flush_after = 0 # measured in pages, 0 disables # - Asynchronous Behavior - @@ -166,7 +165,7 @@ #max_parallel_workers_per_gather = 2 # taken from max_worker_processes #old_snapshot_threshold = -1 # 1min-60d; -1 disables; 0 is immediate # (change requires restart) -#backend_flush_after = 0 # 0 disables, default is 0 +#backend_flush_after = 0 # measured in pages, 0 disables #------------------------------------------------------------------------------ @@ -196,7 +195,7 @@ #wal_buffers = -1 # min 32kB, -1 sets based on shared_buffers # (change requires restart) #wal_writer_delay = 200ms # 1-10000 milliseconds -#wal_writer_flush_after = 1MB # 0 disables +#wal_writer_flush_after = 1MB # measured in pages, 0 disables #commit_delay = 0 # range 0-100000, in microseconds #commit_siblings = 5 # range 1-1000 @@ -207,8 +206,7 @@ #max_wal_size = 1GB #min_wal_size = 80MB #checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0 -#checkpoint_flush_after = 0 # 0 disables, - # default is 256kB on linux, 0 otherwise +#checkpoint_flush_after = 0 # measured in pages, 0 disables #checkpoint_warning = 30s # 0 disables # - Archiving - diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index c8a8c52c3d7..24f9cc8eae2 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -64,11 +64,11 @@ #include "common/file_utils.h" #include "common/restricted_token.h" #include "common/username.h" -#include "mb/pg_wchar.h" +#include "fe_utils/string_utils.h" #include "getaddrinfo.h" #include "getopt_long.h" +#include "mb/pg_wchar.h" #include "miscadmin.h" -#include "fe_utils/string_utils.h" /* Ideally this would be in a .h file, but it hardly seems worth the trouble */ @@ -1095,6 +1095,27 @@ setup_config(void) conflines = replace_token(conflines, "#dynamic_shared_memory_type = posix", repltok); +#if DEFAULT_BACKEND_FLUSH_AFTER > 0 + snprintf(repltok, sizeof(repltok), "#backend_flush_after = %dkB", + DEFAULT_BACKEND_FLUSH_AFTER * (BLCKSZ / 1024)); + conflines = replace_token(conflines, "#backend_flush_after = 0", + repltok); +#endif + +#if DEFAULT_BGWRITER_FLUSH_AFTER > 0 + snprintf(repltok, sizeof(repltok), "#bgwriter_flush_after = %dkB", + DEFAULT_BGWRITER_FLUSH_AFTER * (BLCKSZ / 1024)); + conflines = replace_token(conflines, "#bgwriter_flush_after = 0", + repltok); +#endif + +#if DEFAULT_CHECKPOINT_FLUSH_AFTER > 0 + snprintf(repltok, sizeof(repltok), "#checkpoint_flush_after = %dkB", + DEFAULT_CHECKPOINT_FLUSH_AFTER * (BLCKSZ / 1024)); + conflines = replace_token(conflines, "#checkpoint_flush_after = 0", + repltok); +#endif + #ifndef USE_PREFETCH conflines = replace_token(conflines, "#effective_io_concurrency = 1", diff --git a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h index a2b2b614bec..96885bb9901 100644 --- a/src/include/pg_config_manual.h +++ b/src/include/pg_config_manual.h @@ -148,6 +148,24 @@ #endif /* + * Default and maximum values for backend_flush_after, bgwriter_flush_after + * and checkpoint_flush_after; measured in blocks. Currently, these are + * enabled by default if sync_file_range() exists, ie, only on Linux. Perhaps + * we could also enable by default if we have mmap and msync(MS_ASYNC)? + */ +#ifdef HAVE_SYNC_FILE_RANGE +#define DEFAULT_BACKEND_FLUSH_AFTER 0 /* never enabled by default */ +#define DEFAULT_BGWRITER_FLUSH_AFTER 64 +#define DEFAULT_CHECKPOINT_FLUSH_AFTER 32 +#else +#define DEFAULT_BACKEND_FLUSH_AFTER 0 +#define DEFAULT_BGWRITER_FLUSH_AFTER 0 +#define DEFAULT_CHECKPOINT_FLUSH_AFTER 0 +#endif +/* upper limit for all three variables */ +#define WRITEBACK_MAX_PENDING_FLUSHES 256 + +/* * USE_SSL code should be compiled only when compiling with an SSL * implementation. (Currently, only OpenSSL is supported, but we might add * more implementations in the future.) diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index 821bee5ecea..c543ad6fdec 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -54,17 +54,6 @@ struct WritebackContext; extern PGDLLIMPORT int NBuffers; /* in bufmgr.c */ -#define WRITEBACK_MAX_PENDING_FLUSHES 256 - -/* FIXME: Also default to on for mmap && msync(MS_ASYNC)? */ -#ifdef HAVE_SYNC_FILE_RANGE -#define DEFAULT_CHECKPOINT_FLUSH_AFTER 32 -#define DEFAULT_BGWRITER_FLUSH_AFTER 64 -#else -#define DEFAULT_CHECKPOINT_FLUSH_AFTER 0 -#define DEFAULT_BGWRITER_FLUSH_AFTER 0 -#endif /* HAVE_SYNC_FILE_RANGE */ - extern bool zero_damaged_pages; extern int bgwriter_lru_maxpages; extern double bgwriter_lru_multiplier; |