Re: Incorrect formula for SysV IPC parameters

From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Incorrect formula for SysV IPC parameters
Date: 2016-02-04 12:43:04
Message-ID: CAHGQGwHgBsat29_ZqK3aXg4a5Lsa0JUv579VkGWX3R_g0KOncw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Feb 3, 2016 at 12:51 PM, Kyotaro HORIGUCHI
<horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> wrote:
> Hello, I found that the formulas to calculate SEMMNI and SEMMNS
> are incorrect in 9.2 and later.
>
> http://www.postgresql.org/docs/9.5/static/kernel-resources.html
>
> All of them say that the same thing as following,
>
> | SEMMNI Maximum number of semaphore identifiers (i.e., sets)
> |
> | at least ceil((max_connections + autovacuum_max_workers + 4) / 16)
> |
> | SEMMNS Maximum number of semaphores system-wide
> |
> | ceil((max_connections + autovacuum_max_workers + 4) / 16) * 17
> | plus room for other applications
>
> But actually the number of semaphores PostgreSQL needs is
> calculated as following in 9.4 and later.
>
> numSemas = MaxConnections + NUM_AUXILIARY_PROCS(=4)
> MaxConnections = max_connections + autovacuum_max_workers + 1 +
> max_worker_processes
>
> So, the formula for SEMMNI should be
>
> ceil((max_connections + autovacuum_max_workers + max_worker_processes + 5) / 16)
>
> and SEMMNS should have the same fix.
>
>
> In 9.3 and 9.2, the documentation says the same thing but
> actually it is calculated as following,
>
> numSemas = MaxConnections + NUM_AUXILIARY_PROCS(=4)
> MaxConnections = max_connections + autovacuum_max_workers + 1 +
> GetNumShmemAttachedBgworkers()
>
> Omitting GetNumShmemAttachedBgworkers, the actual formula is
>
> ceil((max_connections + autovacuum_max_workers + 5) / 16)
>
>
> In 9.1, NUM_AUXILIARY_PROCS is 3 so the documentations is correct.
>
>
> I attached two patches for 9.2-9.3 and 9.4-9.6dev
> respectively. patch command complains a bit on applying it on
> 9.2.

Good catch!

ISTM that you also need to change the descriptions about SEMMNI and SEMMNS
under the Table 17-1.

Regards,

--
Fujii Masao

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2016-02-04 12:51:32 Re: postgres_fdw join pushdown (was Re: Custom/Foreign-Join-APIs)
Previous Message Ashutosh Bapat 2016-02-04 12:42:42 Re: postgres_fdw join pushdown (was Re: Custom/Foreign-Join-APIs)