From 17ba50c29aafd2de81462e0aca70c8629076e52c Mon Sep 17 00:00:00 2001 From: Andrey Borodin Date: Sat, 9 May 2020 16:42:07 +0500 Subject: [PATCH v1 1/3] Add GUCs to tune MultiXact SLRUs --- doc/src/sgml/config.sgml | 31 ++++++++++++++++++++++++++ src/backend/access/transam/multixact.c | 8 +++---- src/backend/utils/init/globals.c | 3 +++ src/backend/utils/misc/guc.c | 22 ++++++++++++++++++ src/include/access/multixact.h | 4 ---- src/include/miscadmin.h | 2 ++ 6 files changed, 62 insertions(+), 8 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 3aea1763b4..71aa5c4900 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1746,6 +1746,37 @@ include_dir 'conf.d' + + multixact_offsets_slru_buffers (integer) + + multixact_offsets_slru_buffers configuration parameter + + + + + Specifies the amount of memory to be used for MultiXact offsets. MultiXact offsets + are used to store informaion about offsets of multiple row lockers (caused by SELECT FOR UPDATE and others). + It defaults to 64 kilobytes (64KB). + + + + + + multixact_members_slru_buffers (integer) + + multixact_members_slru_buffers configuration parameter + + + + + Specifies the amount of memory to be used for MultiXact members. MultiXact members + are used to store informaion about XIDs of multiple row lockers. Tipically multixact_members_slru_buffers + is twice more than multixact_offsets_slru_buffers. + It defaults to 128 kilobytes (128KB). + + + + max_stack_depth (integer) diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c index e2aa5c9ce4..d2ac029b98 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -1812,8 +1812,8 @@ MultiXactShmemSize(void) mul_size(sizeof(MultiXactId) * 2, MaxOldestSlot)) size = SHARED_MULTIXACT_STATE_SIZE; - size = add_size(size, SimpleLruShmemSize(NUM_MXACTOFFSET_BUFFERS, 0)); - size = add_size(size, SimpleLruShmemSize(NUM_MXACTMEMBER_BUFFERS, 0)); + size = add_size(size, SimpleLruShmemSize(multixact_offsets_slru_buffers, 0)); + size = add_size(size, SimpleLruShmemSize(multixact_members_slru_buffers, 0)); return size; } @@ -1829,11 +1829,11 @@ MultiXactShmemInit(void) MultiXactMemberCtl->PagePrecedes = MultiXactMemberPagePrecedes; SimpleLruInit(MultiXactOffsetCtl, - "multixact_offset", NUM_MXACTOFFSET_BUFFERS, 0, + "multixact_offset", multixact_offsets_slru_buffers, 0, MultiXactOffsetControlLock, "pg_multixact/offsets", LWTRANCHE_MXACTOFFSET_BUFFERS); SimpleLruInit(MultiXactMemberCtl, - "multixact_member", NUM_MXACTMEMBER_BUFFERS, 0, + "multixact_member", multixact_members_slru_buffers, 0, MultiXactMemberControlLock, "pg_multixact/members", LWTRANCHE_MXACTMEMBER_BUFFERS); diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c index eb19644419..aebfbdb67c 100644 --- a/src/backend/utils/init/globals.c +++ b/src/backend/utils/init/globals.c @@ -148,3 +148,6 @@ int VacuumCostBalance = 0; /* working state for vacuum */ bool VacuumCostActive = false; double vacuum_cleanup_index_scale_factor; + +int multixact_offsets_slru_buffers = 8; +int multixact_members_slru_buffers = 16; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 5bdc02fce2..b139e387f3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -2270,6 +2270,28 @@ static struct config_int ConfigureNamesInt[] = NULL, NULL, NULL }, + { + {"multixact_offsets_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM, + gettext_noop("Sets the number of shared memory buffers used for MultiXact offsets SLRU."), + NULL, + GUC_UNIT_BLOCKS + }, + &multixact_offsets_slru_buffers, + 8, 2, INT_MAX / 2, + NULL, NULL, NULL + }, + + { + {"multixact_members_slru_buffers", PGC_POSTMASTER, RESOURCES_MEM, + gettext_noop("Sets the number of shared memory buffers used for MultiXact members SLRU."), + NULL, + GUC_UNIT_BLOCKS + }, + &multixact_members_slru_buffers, + 16, 2, INT_MAX / 2, + NULL, NULL, NULL + }, + { {"temp_buffers", PGC_USERSET, RESOURCES_MEM, gettext_noop("Sets the maximum number of temporary buffers used by each session."), diff --git a/src/include/access/multixact.h b/src/include/access/multixact.h index af4aac08bd..848398bf1e 100644 --- a/src/include/access/multixact.h +++ b/src/include/access/multixact.h @@ -28,10 +28,6 @@ #define MaxMultiXactOffset ((MultiXactOffset) 0xFFFFFFFF) -/* Number of SLRU buffers to use for multixact */ -#define NUM_MXACTOFFSET_BUFFERS 8 -#define NUM_MXACTMEMBER_BUFFERS 16 - /* * Possible multixact lock modes ("status"). The first four modes are for * tuple locks (FOR KEY SHARE, FOR SHARE, FOR NO KEY UPDATE, FOR UPDATE); the diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 14fa127ab1..95f4633a88 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -161,6 +161,8 @@ extern PGDLLIMPORT int MaxBackends; extern PGDLLIMPORT int MaxConnections; extern PGDLLIMPORT int max_worker_processes; extern PGDLLIMPORT int max_parallel_workers; +extern PGDLLIMPORT int multixact_offsets_slru_buffers; +extern PGDLLIMPORT int multixact_members_slru_buffers; extern PGDLLIMPORT int MyProcPid; extern PGDLLIMPORT pg_time_t MyStartTime; -- 2.24.2 (Apple Git-127)