v20240905-0003-separate-guc-to-allow-benchmarking.patch
text/x-patch
Filename: v20240905-0003-separate-guc-to-allow-benchmarking.patch
Type: text/x-patch
Part: 2
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v20240905-0003
Subject: separate guc to allow benchmarking
| File | + | − |
|---|---|---|
| src/backend/bootstrap/bootstrap.c | 0 | 2 |
| src/backend/postmaster/postmaster.c | 0 | 5 |
| src/backend/tcop/postgres.c | 0 | 3 |
| src/backend/utils/init/postinit.c | 0 | 34 |
| src/backend/utils/misc/guc_tables.c | 10 | 0 |
| src/include/miscadmin.h | 0 | 1 |
From d9f3deaa518a673e4dc8df1ff6e40f47c2637e5e Mon Sep 17 00:00:00 2001
From: Tomas Vondra <tomas@vondra.me>
Date: Thu, 5 Sep 2024 16:52:26 +0200
Subject: [PATCH v20240905 3/4] separate guc to allow benchmarking
---
src/backend/bootstrap/bootstrap.c | 2 --
src/backend/postmaster/postmaster.c | 5 -----
src/backend/tcop/postgres.c | 3 ---
src/backend/utils/init/postinit.c | 34 -----------------------------
src/backend/utils/misc/guc_tables.c | 10 +++++++++
src/include/miscadmin.h | 1 -
6 files changed, 10 insertions(+), 45 deletions(-)
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index ed59dfce893..7637581a184 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -309,8 +309,6 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
InitializeMaxBackends();
- InitializeFastPathLocks();
-
CreateSharedMemoryAndSemaphores();
/*
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index f4a16595d7f..96bc1d1cfed 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -903,11 +903,6 @@ PostmasterMain(int argc, char *argv[])
*/
InitializeMaxBackends();
- /*
- * Also calculate the size of the fast-path lock arrays in PGPROC.
- */
- InitializeFastPathLocks();
-
/*
* Give preloaded libraries a chance to request additional shared memory.
*/
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index f54ae00abca..8bc6bea1135 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -4166,9 +4166,6 @@ PostgresSingleUserMain(int argc, char *argv[],
/* Initialize MaxBackends */
InitializeMaxBackends();
- /* Initialize size of fast-path lock cache. */
- InitializeFastPathLocks();
-
/*
* Give preloaded libraries a chance to request additional shared memory.
*/
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index 1faf756c8d8..3b50ce19a2c 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -557,40 +557,6 @@ InitializeMaxBackends(void)
MAX_BACKENDS)));
}
-/*
- * Initialize the number of fast-path lock slots in PGPROC.
- *
- * This must be called after modules have had the chance to alter GUCs in
- * shared_preload_libraries and before shared memory size is determined.
- *
- * The default max_locks_per_xact=64 means 4 groups by default.
- *
- * We allow anything between 1 and 1024 groups, with the usual power-of-2
- * logic. The 1 is the "old" value before allowing multiple groups, 1024
- * is an arbitrary limit (matching max_locks_per_xact = 16k). Values over
- * 1024 are unlikely to be beneficial - we're likely to hit other
- * bottlenecks long before that.
- */
-void
-InitializeFastPathLocks(void)
-{
- Assert(FastPathLockGroupsPerBackend == 0);
-
- /* we need at least one group */
- FastPathLockGroupsPerBackend = 1;
-
- while (FastPathLockGroupsPerBackend < FP_LOCK_GROUPS_PER_BACKEND_MAX)
- {
- /* stop once we exceed max_locks_per_xact */
- if (FastPathLockGroupsPerBackend * FP_LOCK_SLOTS_PER_GROUP >= max_locks_per_xact)
- break;
-
- FastPathLockGroupsPerBackend *= 2;
- }
-
- Assert(FastPathLockGroupsPerBackend <= FP_LOCK_GROUPS_PER_BACKEND_MAX);
-}
-
/*
* Early initialization of a backend (either standalone or under postmaster).
* This happens even before InitPostgres.
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 686309db58b..cef6341979f 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -2788,6 +2788,16 @@ struct config_int ConfigureNamesInt[] =
NULL, NULL, NULL
},
+ {
+ {"fastpath_lock_groups", PGC_POSTMASTER, LOCK_MANAGEMENT,
+ gettext_noop("Sets the maximum number of locks per transaction."),
+ gettext_noop("number of groups in the fast-path lock array.")
+ },
+ &FastPathLockGroupsPerBackend,
+ 1, 1, INT_MAX,
+ NULL, NULL, NULL
+ },
+
{
{"max_pred_locks_per_transaction", PGC_POSTMASTER, LOCK_MANAGEMENT,
gettext_noop("Sets the maximum number of predicate locks per transaction."),
diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h
index e26d108a470..25348e71eb9 100644
--- a/src/include/miscadmin.h
+++ b/src/include/miscadmin.h
@@ -475,7 +475,6 @@ extern PGDLLIMPORT ProcessingMode Mode;
#define INIT_PG_OVERRIDE_ROLE_LOGIN 0x0004
extern void pg_split_opts(char **argv, int *argcp, const char *optstr);
extern void InitializeMaxBackends(void);
-extern void InitializeFastPathLocks(void);
extern void InitPostgres(const char *in_dbname, Oid dboid,
const char *username, Oid useroid,
bits32 flags,
--
2.46.0