Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfc34b0d

Browse files
committed
Introduce a maintenance_io_concurrency setting.
Introduce a GUC and a tablespace option to control I/O prefetching, muchlike effective_io_concurrency, but for work that is done on behalf ofmany client sessions.Use the new setting in heapam.c instead of the hard-coded formulaeffective_io_concurrency + 10 introduced by commit558a916. Go witha default value of 10 for now, because it's a round number pretty closeto the value used for that existing case.Discussion:https://postgr.es/m/CA%2BhUKGJUw08dPs_3EUcdO6M90GnjofPYrWp4YSLaBkgYwS-AqA%40mail.gmail.com
1 parentb09ff53 commitfc34b0d

File tree

12 files changed

+109
-23
lines changed

12 files changed

+109
-23
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2229,6 +2229,26 @@ include_dir 'conf.d'
22292229
</listitem>
22302230
</varlistentry>
22312231

2232+
<varlistentry id="guc-maintenance-io-concurrency" xreflabel="maintenance_io_concurrency">
2233+
<term><varname>maintenance_io_concurrency</varname> (<type>integer</type>)
2234+
<indexterm>
2235+
<primary><varname>maintenance_io_concurrency</varname> configuration parameter</primary>
2236+
</indexterm>
2237+
</term>
2238+
<listitem>
2239+
<para>
2240+
Similar to <varname>effective_io_concurrency</varname>, but used
2241+
for maintenance work that is done on behalf of many client sessions.
2242+
</para>
2243+
<para>
2244+
The default is 10 on supported systems, otherwise 0. This value can
2245+
be overridden for tables in a particular tablespace by setting the
2246+
tablespace parameter of the same name (see
2247+
<xref linkend="sql-altertablespace"/>).
2248+
</para>
2249+
</listitem>
2250+
</varlistentry>
2251+
22322252
<varlistentry id="guc-max-worker-processes" xreflabel="max_worker_processes">
22332253
<term><varname>max_worker_processes</varname> (<type>integer</type>)
22342254
<indexterm>

‎doc/src/sgml/ref/alter_tablespace.sgml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,16 @@ ALTER TABLESPACE <replaceable>name</replaceable> RESET ( <replaceable class="par
8484
<para>
8585
A tablespace parameter to be set or reset. Currently, the only
8686
available parameters are <varname>seq_page_cost</varname>,
87-
<varname>random_page_cost</varname> and <varname>effective_io_concurrency</varname>.
88-
Setting either value for a particular tablespace will override the
87+
<varname>random_page_cost</varname>, <varname>effective_io_concurrency</varname>
88+
and <varname>maintenance_io_concurrency</varname>.
89+
Setting these values for a particular tablespace will override the
8990
planner's usual estimate of the cost of reading pages from tables in
90-
that tablespace, as established by the configuration parameters of the
91+
that tablespace, and the executor's prefetching behavior, as established
92+
by the configuration parameters of the
9193
same name (see <xref linkend="guc-seq-page-cost"/>,
9294
<xref linkend="guc-random-page-cost"/>,
93-
<xref linkend="guc-effective-io-concurrency"/>). This may be useful if
95+
<xref linkend="guc-effective-io-concurrency"/>,
96+
<xref linkend="guc-maintenance-io-concurrency"/>). This may be useful if
9497
one tablespace is located on a disk which is faster or slower than the
9598
remainder of the I/O subsystem.
9699
</para>

‎doc/src/sgml/ref/create_tablespace.sgml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,16 @@ CREATE TABLESPACE <replaceable class="parameter">tablespace_name</replaceable>
106106
<para>
107107
A tablespace parameter to be set or reset. Currently, the only
108108
available parameters are <varname>seq_page_cost</varname>,
109-
<varname>random_page_cost</varname> and <varname>effective_io_concurrency</varname>.
110-
Setting either value for a particular tablespace will override the
109+
<varname>random_page_cost</varname>, <varname>effective_io_concurrency</varname>
110+
and <varname>maintenance_io_concurrency</varname>.
111+
Setting these values for a particular tablespace will override the
111112
planner's usual estimate of the cost of reading pages from tables in
112-
that tablespace, as established by the configuration parameters of the
113+
that tablespace, and the executor's prefetching behavior, as established
114+
by the configuration parameters of the
113115
same name (see <xref linkend="guc-seq-page-cost"/>,
114116
<xref linkend="guc-random-page-cost"/>,
115-
<xref linkend="guc-effective-io-concurrency"/>). This may be useful if
117+
<xref linkend="guc-effective-io-concurrency"/>,
118+
<xref linkend="guc-maintenance-io-concurrency"/>). This may be useful if
116119
one tablespace is located on a disk which is faster or slower than the
117120
remainder of the I/O subsystem.
118121
</para>

‎src/backend/access/common/reloptions.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,19 @@ static relopt_int intRelOpts[] =
349349
-1,0,MAX_IO_CONCURRENCY
350350
#else
351351
0,0,0
352+
#endif
353+
},
354+
{
355+
{
356+
"maintenance_io_concurrency",
357+
"Number of simultaneous requests that can be handled efficiently by the disk subsystem for maintenance work.",
358+
RELOPT_KIND_TABLESPACE,
359+
ShareUpdateExclusiveLock
360+
},
361+
#ifdefUSE_PREFETCH
362+
-1,0,MAX_IO_CONCURRENCY
363+
#else
364+
0,0,0
352365
#endif
353366
},
354367
{
@@ -1700,7 +1713,8 @@ tablespace_reloptions(Datum reloptions, bool validate)
17001713
staticconstrelopt_parse_elttab[]= {
17011714
{"random_page_cost",RELOPT_TYPE_REAL, offsetof(TableSpaceOpts,random_page_cost)},
17021715
{"seq_page_cost",RELOPT_TYPE_REAL, offsetof(TableSpaceOpts,seq_page_cost)},
1703-
{"effective_io_concurrency",RELOPT_TYPE_INT, offsetof(TableSpaceOpts,effective_io_concurrency)}
1716+
{"effective_io_concurrency",RELOPT_TYPE_INT, offsetof(TableSpaceOpts,effective_io_concurrency)},
1717+
{"maintenance_io_concurrency",RELOPT_TYPE_INT, offsetof(TableSpaceOpts,maintenance_io_concurrency)}
17041718
};
17051719

17061720
return (bytea*)build_reloptions(reloptions,validate,

‎src/backend/access/heap/heapam.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7003,7 +7003,6 @@ heap_compute_xid_horizon_for_tuples(Relation rel,
70037003
Pagehpage;
70047004
#ifdefUSE_PREFETCH
70057005
XidHorizonPrefetchStateprefetch_state;
7006-
intio_concurrency;
70077006
intprefetch_distance;
70087007
#endif
70097008

@@ -7026,24 +7025,15 @@ heap_compute_xid_horizon_for_tuples(Relation rel,
70267025
/*
70277026
* Compute the prefetch distance that we will attempt to maintain.
70287027
*
7029-
* We don't use the regular formula to determine how much to prefetch
7030-
* here, but instead just add a constant to effective_io_concurrency.
7031-
* That's because it seems best to do some prefetching here even when
7032-
* effective_io_concurrency is set to 0, but if the DBA thinks it's OK to
7033-
* do more prefetching for other operations, then it's probably OK to do
7034-
* more prefetching in this case, too. It may be that this formula is too
7035-
* simplistic, but at the moment there is no evidence of that or any idea
7036-
* about what would work better.
7037-
*
70387028
* Since the caller holds a buffer lock somewhere in rel, we'd better make
70397029
* sure that isn't a catalog relation before we call code that does
70407030
* syscache lookups, to avoid risk of deadlock.
70417031
*/
70427032
if (IsCatalogRelation(rel))
7043-
io_concurrency=effective_io_concurrency;
7033+
prefetch_distance=maintenance_io_concurrency;
70447034
else
7045-
io_concurrency=get_tablespace_io_concurrency(rel->rd_rel->reltablespace);
7046-
prefetch_distance=Min((io_concurrency)+10,MAX_IO_CONCURRENCY);
7035+
prefetch_distance=
7036+
get_tablespace_maintenance_io_concurrency(rel->rd_rel->reltablespace);
70477037

70487038
/* Start prefetching. */
70497039
xid_horizon_prefetch_buffer(rel,&prefetch_state,prefetch_distance);

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ booltrack_io_timing = false;
119119
*/
120120
inteffective_io_concurrency=0;
121121

122+
/*
123+
* Like effective_io_concurrency, but used by maintenance code paths that might
124+
* benefit from a higher setting because they work on behalf of many sessions.
125+
* Overridden by the tablespace setting of the same name.
126+
*/
127+
intmaintenance_io_concurrency=0;
128+
122129
/*
123130
* GUC variables about triggering kernel writeback for buffers written; OS
124131
* dependent defaults are set via the GUC mechanism.

‎src/backend/utils/cache/spccache.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,17 @@ get_tablespace_io_concurrency(Oid spcid)
221221
else
222222
returnspc->opts->effective_io_concurrency;
223223
}
224+
225+
/*
226+
* get_tablespace_maintenance_io_concurrency
227+
*/
228+
int
229+
get_tablespace_maintenance_io_concurrency(Oidspcid)
230+
{
231+
TableSpaceCacheEntry*spc=get_tablespace(spcid);
232+
233+
if (!spc->opts||spc->opts->maintenance_io_concurrency<0)
234+
returnmaintenance_io_concurrency;
235+
else
236+
returnspc->opts->maintenance_io_concurrency;
237+
}

‎src/backend/utils/misc/guc.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ static bool check_autovacuum_max_workers(int *newval, void **extra, GucSource so
196196
staticboolcheck_max_wal_senders(int*newval,void**extra,GucSourcesource);
197197
staticboolcheck_autovacuum_work_mem(int*newval,void**extra,GucSourcesource);
198198
staticboolcheck_effective_io_concurrency(int*newval,void**extra,GucSourcesource);
199+
staticboolcheck_maintenance_io_concurrency(int*newval,void**extra,GucSourcesource);
199200
staticvoidassign_pgstat_temp_directory(constchar*newval,void*extra);
200201
staticboolcheck_application_name(char**newval,void**extra,GucSourcesource);
201202
staticvoidassign_application_name(constchar*newval,void*extra);
@@ -2884,6 +2885,24 @@ static struct config_int ConfigureNamesInt[] =
28842885
check_effective_io_concurrency,NULL,NULL
28852886
},
28862887

2888+
{
2889+
{"maintenance_io_concurrency",
2890+
PGC_USERSET,
2891+
RESOURCES_ASYNCHRONOUS,
2892+
gettext_noop("A variant of effective_io_concurrency that is used for maintenance work."),
2893+
NULL,
2894+
GUC_EXPLAIN
2895+
},
2896+
&maintenance_io_concurrency,
2897+
#ifdefUSE_PREFETCH
2898+
10,
2899+
#else
2900+
0,
2901+
#endif
2902+
0,MAX_IO_CONCURRENCY,
2903+
check_maintenance_io_concurrency,NULL,NULL
2904+
},
2905+
28872906
{
28882907
{"backend_flush_after",PGC_USERSET,RESOURCES_ASYNCHRONOUS,
28892908
gettext_noop("Number of pages after which previously performed writes are flushed to disk."),
@@ -11466,6 +11485,19 @@ check_effective_io_concurrency(int *newval, void **extra, GucSource source)
1146611485
return true;
1146711486
}
1146811487

11488+
staticbool
11489+
check_maintenance_io_concurrency(int*newval,void**extra,GucSourcesource)
11490+
{
11491+
#ifndefUSE_PREFETCH
11492+
if (*newval!=0)
11493+
{
11494+
GUC_check_errdetail("maintenance_io_concurrency must be set to 0 on platforms that lack posix_fadvise().");
11495+
return false;
11496+
}
11497+
#endif/* USE_PREFETCH */
11498+
return true;
11499+
}
11500+
1146911501
staticvoid
1147011502
assign_pgstat_temp_directory(constchar*newval,void*extra)
1147111503
{

‎src/bin/psql/tab-complete.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2140,7 +2140,7 @@ psql_completion(const char *text, int start, int end)
21402140
/* ALTER TABLESPACE <foo> SET|RESET ( */
21412141
elseif (Matches("ALTER","TABLESPACE",MatchAny,"SET|RESET","("))
21422142
COMPLETE_WITH("seq_page_cost","random_page_cost",
2143-
"effective_io_concurrency");
2143+
"effective_io_concurrency","maintenance_io_concurrency");
21442144

21452145
/* ALTER TEXT SEARCH */
21462146
elseif (Matches("ALTER","TEXT","SEARCH"))

‎src/include/commands/tablespace.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ typedef struct TableSpaceOpts
4040
float8random_page_cost;
4141
float8seq_page_cost;
4242
inteffective_io_concurrency;
43+
intmaintenance_io_concurrency;
4344
}TableSpaceOpts;
4445

4546
externOidCreateTableSpace(CreateTableSpaceStmt*stmt);

‎src/include/storage/bufmgr.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ extern intbgwriter_lru_maxpages;
5858
externdoublebgwriter_lru_multiplier;
5959
externbooltrack_io_timing;
6060
externinteffective_io_concurrency;
61+
externintmaintenance_io_concurrency;
6162

6263
externintcheckpoint_flush_after;
6364
externintbackend_flush_after;

‎src/include/utils/spccache.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@
1616
voidget_tablespace_page_costs(Oidspcid,float8*spc_random_page_cost,
1717
float8*spc_seq_page_cost);
1818
intget_tablespace_io_concurrency(Oidspcid);
19+
intget_tablespace_maintenance_io_concurrency(Oidspcid);
1920

2021
#endif/* SPCCACHE_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp