Re: Estimating HugePages Requirements?
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: "Bossart, Nathan" <bossartn@amazon.com>
Cc: Mark Dilger <mark.dilger@enterprisedb.com>, Don Seiler <don@seiler.us>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2021-08-10T03:42:05Z
Lists: pgsql-hackers
Hi,
On 2021-08-09 22:57:18 +0000, Bossart, Nathan wrote:
> @@ -1026,6 +1031,18 @@ PostmasterMain(int argc, char *argv[])
> */
> InitializeMaxBackends();
>
> + if (output_shmem)
> + {
> + char output[64];
> + Size size;
> +
> + size = CreateSharedMemoryAndSemaphores(true);
> + sprintf(output, "%zu", size);
> +
> + puts(output);
> + ExitPostmaster(0);
> + }
I don't like putting this into PostmasterMain(). Either BootstrapMain()
(specifically checker mode) or GucInfoMain() seem like better places.
> -void
> -CreateSharedMemoryAndSemaphores(void)
> +Size
> +CreateSharedMemoryAndSemaphores(bool size_only)
> {
> PGShmemHeader *shim = NULL;
>
> @@ -161,6 +161,9 @@ CreateSharedMemoryAndSemaphores(void)
> /* might as well round it off to a multiple of a typical page size */
> size = add_size(size, 8192 - (size % 8192));
>
> + if (size_only)
> + return size;
> +
> elog(DEBUG3, "invoking IpcMemoryCreate(size=%zu)", size);
>
> /*
> @@ -288,4 +291,6 @@ CreateSharedMemoryAndSemaphores(void)
> */
> if (shmem_startup_hook)
> shmem_startup_hook();
> +
> + return 0;
> }
That seems like an ugly API to me. Why don't we split the size
determination and shmem creation functions into two?
Greetings,
Andres Freund
Commits
-
Silence extra logging when using "postgres -C" on runtime-computed GUCs
- 8bbf8461a3a2 15.0 landed
-
doc: Improve postgres command for shared_memory_size_in_huge_pages
- bbd4951b73ec 15.0 landed
-
Introduce GUC shared_memory_size_in_huge_pages
- 43c1c4f65eab 15.0 landed
-
Support "postgres -C" with runtime-computed GUCs
- 0c39c292077e 15.0 landed
-
Make shared_memory_size a preset option
- 3b231596ccfc 15.0 landed
-
Introduce GUC shared_memory_size
- bd1788051b02 15.0 landed
-
Move the shared memory size calculation to its own function
- 0bd305ee1d42 15.0 landed
-
Add new GUC, max_worker_processes, limiting number of bgworkers.
- 6bc8ef0b7f1f 9.4.0 cited