aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/ipc/ipci.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2021-09-08 12:02:30 +0900
committerMichael Paquier <michael@paquier.xyz>2021-09-08 12:02:30 +0900
commitbd1788051b02cfddcd9ef0e2fd094972f372b8fd (patch)
treea0bc449c2d8a6b6e91fe96d7b2353c3d91339085 /src/backend/storage/ipc/ipci.c
parentfd0625c7a9c679c0c1e896014b8f49a489c3a245 (diff)
downloadpostgresql-bd1788051b02cfddcd9ef0e2fd094972f372b8fd.tar.gz
postgresql-bd1788051b02cfddcd9ef0e2fd094972f372b8fd.zip
Introduce GUC shared_memory_size
This runtime-computed GUC shows the size of the server's main shared memory area, taking into account the amount of shared memory allocated by extensions as this is calculated after processing shared_preload_libraries. Author: Nathan Bossart Discussion: https://postgr.es/m/F2772387-CE0F-46BF-B5F1-CC55516EB885@amazon.com
Diffstat (limited to 'src/backend/storage/ipc/ipci.c')
-rw-r--r--src/backend/storage/ipc/ipci.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/backend/storage/ipc/ipci.c b/src/backend/storage/ipc/ipci.c
index 64bc16fa848..1a408ad77e5 100644
--- a/src/backend/storage/ipc/ipci.c
+++ b/src/backend/storage/ipc/ipci.c
@@ -313,3 +313,25 @@ CreateSharedMemoryAndSemaphores(void)
if (shmem_startup_hook)
shmem_startup_hook();
}
+
+/*
+ * InitializeShmemGUCs
+ *
+ * This function initializes runtime-computed GUCs related to the amount of
+ * shared memory required for the current configuration.
+ */
+void
+InitializeShmemGUCs(void)
+{
+ char buf[64];
+ Size size_b;
+ Size size_mb;
+
+ /*
+ * Calculate the shared memory size and round up to the nearest megabyte.
+ */
+ size_b = CalculateShmemSize(NULL);
+ size_mb = add_size(size_b, (1024 * 1024) - 1) / (1024 * 1024);
+ sprintf(buf, "%lu", size_mb);
+ SetConfigOption("shared_memory_size", buf, PGC_INTERNAL, PGC_S_OVERRIDE);
+}