Martin Husemann <[email protected]> writes:

> To get a concrete idea of what we are talking about, here are the 
> sizes on amd64:
>
>         /* Allocate the wired memory for our structures */
>         sz = ALIGN(seminfo.semmni * sizeof(struct semid_ds)) +
>             ALIGN(seminfo.semmns * sizeof(struct __sem)) +
>             ALIGN(seminfo.semmni * sizeof(kcondvar_t)) +
>             ALIGN(seminfo.semmnu * seminfo.semusz);
>         sz = round_page(sz);
>
> and:
> (gdb) p sizeof(struct semid_ds)
> $2 = 64
> (gdb) p sizeof(struct __sem)
> $3 = 12
> (gdb) p sizeof(kcondvar_t)
> $4 = 16
>
> so the suggested change costs 22*64 + 196*12 = 3760 bytes
> plus maybe a bit of alignment - so 1 more wired page most likely.

That sounds like it's totally ok.  We have pages and pages of bloated
kernel code already, and the same effort could probably save a page
someplace else.

> However, most machines never need it (or not much of it), so I wonder if
> we could (relatively simple) init it on first use only (and then maybe
> scaled by KVA/RAM details).

As I said to Taylor, if somebody wants to make it auto-scaling, I don't
object, as long as any many that can run postgresql in the first place
has enough semaphores.

I don't want to refrain from a simple reasonable fix that addresses a
real issue (pgsql 18 not working out of the box) because of a future
better fix, and/or a future better fix that's too complicated for
pullups.

If the simple fix goes in, that does not make it harder (rounding effort
to 5 minutes) to make this fancier later.

Reply via email to