From e273a508592236dbf5c60417b5878961c2483bca Mon Sep 17 00:00:00 2001 From: Andrey Borodin Date: Sat, 9 May 2020 16:42:07 +0500 Subject: [PATCH v1106 4/4] 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 | 2 ++ src/backend/utils/misc/guc.c | 22 ++++++++++++++++++ src/include/access/multixact.h | 4 ---- src/include/miscadmin.h | 2 ++ 6 files changed, 61 insertions(+), 8 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 15fb2f2bde..44ebacc713 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1673,6 +1673,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 5d2bbb1ca6..31324714b8 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -1844,8 +1844,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; } @@ -1861,11 +1861,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 22af834150..5a8517f8eb 100644 --- a/src/backend/utils/init/globals.c +++ b/src/backend/utils/init/globals.c @@ -149,3 +149,5 @@ bool VacuumCostActive = false; double vacuum_cleanup_index_scale_factor; int multixact_local_cache_entries = 256; +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 b54a063782..578452d757 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -2036,6 +2036,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 18fe380c5f..6e14fb7b29 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 11c3c8e6c5..e3fd0a264d 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -160,6 +160,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 multixact_local_cache_entries; -- 2.24.3 (Apple Git-128)