aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2020-03-16 12:31:34 +1300
committerThomas Munro <tmunro@postgresql.org>2020-03-16 17:14:26 +1300
commitfc34b0d9de27ab5ac2887da00b3892bdabd89e45 (patch)
treebfa65c51892f19538b6e7e53633654ddce5eb989 /src/backend/utils
parentb09ff53667ffc986371ec8ffa372916ad460220d (diff)
downloadpostgresql-fc34b0d9de27ab5ac2887da00b3892bdabd89e45.tar.gz
postgresql-fc34b0d9de27ab5ac2887da00b3892bdabd89e45.zip
Introduce a maintenance_io_concurrency setting.
Introduce a GUC and a tablespace option to control I/O prefetching, much like effective_io_concurrency, but for work that is done on behalf of many client sessions. Use the new setting in heapam.c instead of the hard-coded formula effective_io_concurrency + 10 introduced by commit 558a9165e08. Go with a default value of 10 for now, because it's a round number pretty close to the value used for that existing case. Discussion: https://postgr.es/m/CA%2BhUKGJUw08dPs_3EUcdO6M90GnjofPYrWp4YSLaBkgYwS-AqA%40mail.gmail.com
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/cache/spccache.c14
-rw-r--r--src/backend/utils/misc/guc.c32
2 files changed, 46 insertions, 0 deletions
diff --git a/src/backend/utils/cache/spccache.c b/src/backend/utils/cache/spccache.c
index c4a0f719fb5..e0c3c1b1c11 100644
--- a/src/backend/utils/cache/spccache.c
+++ b/src/backend/utils/cache/spccache.c
@@ -221,3 +221,17 @@ get_tablespace_io_concurrency(Oid spcid)
else
return spc->opts->effective_io_concurrency;
}
+
+/*
+ * get_tablespace_maintenance_io_concurrency
+ */
+int
+get_tablespace_maintenance_io_concurrency(Oid spcid)
+{
+ TableSpaceCacheEntry *spc = get_tablespace(spcid);
+
+ if (!spc->opts || spc->opts->maintenance_io_concurrency < 0)
+ return maintenance_io_concurrency;
+ else
+ return spc->opts->maintenance_io_concurrency;
+}
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 326e773b25f..68082315acd 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -196,6 +196,7 @@ static bool check_autovacuum_max_workers(int *newval, void **extra, GucSource so
static bool check_max_wal_senders(int *newval, void **extra, GucSource source);
static bool check_autovacuum_work_mem(int *newval, void **extra, GucSource source);
static bool check_effective_io_concurrency(int *newval, void **extra, GucSource source);
+static bool check_maintenance_io_concurrency(int *newval, void **extra, GucSource source);
static void assign_pgstat_temp_directory(const char *newval, void *extra);
static bool check_application_name(char **newval, void **extra, GucSource source);
static void assign_application_name(const char *newval, void *extra);
@@ -2885,6 +2886,24 @@ static struct config_int ConfigureNamesInt[] =
},
{
+ {"maintenance_io_concurrency",
+ PGC_USERSET,
+ RESOURCES_ASYNCHRONOUS,
+ gettext_noop("A variant of effective_io_concurrency that is used for maintenance work."),
+ NULL,
+ GUC_EXPLAIN
+ },
+ &maintenance_io_concurrency,
+#ifdef USE_PREFETCH
+ 10,
+#else
+ 0,
+#endif
+ 0, MAX_IO_CONCURRENCY,
+ check_maintenance_io_concurrency, NULL, NULL
+ },
+
+ {
{"backend_flush_after", PGC_USERSET, RESOURCES_ASYNCHRONOUS,
gettext_noop("Number of pages after which previously performed writes are flushed to disk."),
NULL,
@@ -11466,6 +11485,19 @@ check_effective_io_concurrency(int *newval, void **extra, GucSource source)
return true;
}
+static bool
+check_maintenance_io_concurrency(int *newval, void **extra, GucSource source)
+{
+#ifndef USE_PREFETCH
+ if (*newval != 0)
+ {
+ GUC_check_errdetail("maintenance_io_concurrency must be set to 0 on platforms that lack posix_fadvise().");
+ return false;
+ }
+#endif /* USE_PREFETCH */
+ return true;
+}
+
static void
assign_pgstat_temp_directory(const char *newval, void *extra)
{