Re: Estimating HugePages Requirements?

From: Andres Freund <andres(at)anarazel(dot)de>
To: "Bossart, Nathan" <bossartn(at)amazon(dot)com>
Cc: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>, Don Seiler <don(at)seiler(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Estimating HugePages Requirements?
Date: 2021-08-10 03:42:05
Message-ID: 20210810034205.r72j5uouynepj4f2@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin 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

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message otar shavadze 2021-08-10 14:01:49 Index usage statistic for last X hours
Previous Message Andres Freund 2021-08-10 03:38:32 Re: Estimating HugePages Requirements?

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2021-08-10 04:17:52 Re: alter table set TABLE ACCESS METHOD
Previous Message Andres Freund 2021-08-10 03:38:32 Re: Estimating HugePages Requirements?