From 649c5c25349c32aecf02fad46197234af95f9860 Mon Sep 17 00:00:00 2001 From: Alexander Korotkov Date: Mon, 26 Oct 2020 03:44:50 +0300 Subject: [PATCH v1106 2/4] Make MultiXact local cache size configurable --- doc/src/sgml/config.sgml | 37 ++++++++++++++++++++++++++ src/backend/access/transam/multixact.c | 2 +- src/backend/utils/init/globals.c | 2 ++ src/backend/utils/misc/guc.c | 10 +++++++ src/include/miscadmin.h | 2 ++ 5 files changed, 52 insertions(+), 1 deletion(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 3570b422be..15fb2f2bde 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -1637,6 +1637,43 @@ include_dir 'conf.d' + + logical_decoding_work_mem (integer) + + logical_decoding_work_mem configuration parameter + + + + + Specifies the maximum amount of memory to be used by logical decoding, + before some of the decoded changes are written to local disk. This + limits the amount of memory used by logical streaming replication + connections. It defaults to 64 megabytes (64MB). + Since each replication connection only uses a single buffer of this size, + and an installation normally doesn't have many such connections + concurrently (as limited by max_wal_senders), it's + safe to set this value significantly higher than work_mem, + reducing the amount of decoded changes written to disk. + + + + + + multixact_local_cache_entries (integer) + + multixact_local_cache_entries configuration parameter + + + + + Specifies the number cached MultiXact by backend. Any SLRU lookup is preceeded + by cache lookup. Higher numbers of cache size help to deduplicate lock sets, while + lower values make cache lookup faster. + It defaults to 256. + + + + max_stack_depth (integer) diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c index 5ca10a139a..6203be0aa3 100644 --- a/src/backend/access/transam/multixact.c +++ b/src/backend/access/transam/multixact.c @@ -1591,7 +1591,7 @@ mXactCachePut(MultiXactId multi, int nmembers, MultiXactMember *members) qsort(entry->members, nmembers, sizeof(MultiXactMember), mxactMemberComparator); dlist_push_head(&MXactCache, &entry->node); - if (MXactCacheMembers++ >= MAX_CACHE_ENTRIES) + if (MXactCacheMembers++ >= multixact_local_cache_entries) { dlist_node *node; mXactCacheEnt *entry; diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c index f7d6617a13..22af834150 100644 --- a/src/backend/utils/init/globals.c +++ b/src/backend/utils/init/globals.c @@ -147,3 +147,5 @@ int VacuumCostBalance = 0; /* working state for vacuum */ bool VacuumCostActive = false; double vacuum_cleanup_index_scale_factor; + +int multixact_local_cache_entries = 256; diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 710344c72b..b54a063782 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -2026,6 +2026,16 @@ static struct config_int ConfigureNamesInt[] = NULL, NULL, NULL }, + { + {"multixact_local_cache_entries", PGC_SUSET, RESOURCES_MEM, + gettext_noop("Sets the number of cached MultiXact by backend."), + NULL + }, + &multixact_local_cache_entries, + 256, 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/miscadmin.h b/src/include/miscadmin.h index 8024145535..11c3c8e6c5 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -161,6 +161,8 @@ extern PGDLLIMPORT int MaxConnections; extern PGDLLIMPORT int max_worker_processes; extern PGDLLIMPORT int max_parallel_workers; +extern PGDLLIMPORT int multixact_local_cache_entries; + extern PGDLLIMPORT int MyProcPid; extern PGDLLIMPORT pg_time_t MyStartTime; extern PGDLLIMPORT struct Port *MyProcPort; -- 2.24.3 (Apple Git-128)