diff options
author | Thomas Munro <tmunro@postgresql.org> | 2020-03-16 12:31:34 +1300 |
---|---|---|
committer | Thomas Munro <tmunro@postgresql.org> | 2020-03-16 17:14:26 +1300 |
commit | fc34b0d9de27ab5ac2887da00b3892bdabd89e45 (patch) | |
tree | bfa65c51892f19538b6e7e53633654ddce5eb989 /src/backend/access | |
parent | b09ff53667ffc986371ec8ffa372916ad460220d (diff) | |
download | postgresql-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/access')
-rw-r--r-- | src/backend/access/common/reloptions.c | 16 | ||||
-rw-r--r-- | src/backend/access/heap/heapam.c | 16 |
2 files changed, 18 insertions, 14 deletions
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c index c3d45c7a248..ec207d3b26c 100644 --- a/src/backend/access/common/reloptions.c +++ b/src/backend/access/common/reloptions.c @@ -353,6 +353,19 @@ static relopt_int intRelOpts[] = }, { { + "maintenance_io_concurrency", + "Number of simultaneous requests that can be handled efficiently by the disk subsystem for maintenance work.", + RELOPT_KIND_TABLESPACE, + ShareUpdateExclusiveLock + }, +#ifdef USE_PREFETCH + -1, 0, MAX_IO_CONCURRENCY +#else + 0, 0, 0 +#endif + }, + { + { "parallel_workers", "Number of parallel processes that can be used per executor node for this relation.", RELOPT_KIND_HEAP, @@ -1700,7 +1713,8 @@ tablespace_reloptions(Datum reloptions, bool validate) static const relopt_parse_elt tab[] = { {"random_page_cost", RELOPT_TYPE_REAL, offsetof(TableSpaceOpts, random_page_cost)}, {"seq_page_cost", RELOPT_TYPE_REAL, offsetof(TableSpaceOpts, seq_page_cost)}, - {"effective_io_concurrency", RELOPT_TYPE_INT, offsetof(TableSpaceOpts, effective_io_concurrency)} + {"effective_io_concurrency", RELOPT_TYPE_INT, offsetof(TableSpaceOpts, effective_io_concurrency)}, + {"maintenance_io_concurrency", RELOPT_TYPE_INT, offsetof(TableSpaceOpts, maintenance_io_concurrency)} }; return (bytea *) build_reloptions(reloptions, validate, diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 5a32e62ed0e..29694b8aa4a 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -7003,7 +7003,6 @@ heap_compute_xid_horizon_for_tuples(Relation rel, Page hpage; #ifdef USE_PREFETCH XidHorizonPrefetchState prefetch_state; - int io_concurrency; int prefetch_distance; #endif @@ -7026,24 +7025,15 @@ heap_compute_xid_horizon_for_tuples(Relation rel, /* * Compute the prefetch distance that we will attempt to maintain. * - * We don't use the regular formula to determine how much to prefetch - * here, but instead just add a constant to effective_io_concurrency. - * That's because it seems best to do some prefetching here even when - * effective_io_concurrency is set to 0, but if the DBA thinks it's OK to - * do more prefetching for other operations, then it's probably OK to do - * more prefetching in this case, too. It may be that this formula is too - * simplistic, but at the moment there is no evidence of that or any idea - * about what would work better. - * * Since the caller holds a buffer lock somewhere in rel, we'd better make * sure that isn't a catalog relation before we call code that does * syscache lookups, to avoid risk of deadlock. */ if (IsCatalogRelation(rel)) - io_concurrency = effective_io_concurrency; + prefetch_distance = maintenance_io_concurrency; else - io_concurrency = get_tablespace_io_concurrency(rel->rd_rel->reltablespace); - prefetch_distance = Min((io_concurrency) + 10, MAX_IO_CONCURRENCY); + prefetch_distance = + get_tablespace_maintenance_io_concurrency(rel->rd_rel->reltablespace); /* Start prefetching. */ xid_horizon_prefetch_buffer(rel, &prefetch_state, prefetch_distance); |