mirror of
https://github.com/postgres/postgres.git
synced 2025-08-25 20:23:07 +03:00
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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user