Re: OpenBSD versus semaphores

Поиск
Список
Период
Сортировка
От Abel Abraham Camarillo Ojeda
Тема Re: OpenBSD versus semaphores
Дата
Msg-id CAPD=2NiKs8GBFdpf-ECVE3SXsmOmprDKivueXpGLTREz901o1g@mail.gmail.com
обсуждение исходный текст
Ответ на OpenBSD versus semaphores  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers


On Tue, Jan 8, 2019 at 12:14 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
I've been toying with OpenBSD lately, and soon noticed a seriously
annoying problem for running Postgres on it: by default, its limits
for SysV semaphores are only SEMMNS=60, SEMMNI=10.  Not only does that
greatly constrain the number of connections for a single installation,
it means that our TAP tests fail because you can't start two postmasters
concurrently (cf [1]).

Raising the annoyance factor considerably, AFAICT the only way to
increase these settings is to build your own custom kernel.

This is not accurate, you can change this values via sysctl(1), extracted from OpenBSD postgresql port:

Tuning for busy servers
=======================
The default sizes in the GENERIC kernel for SysV semaphores are only
just large enough for a database with the default configuration
(max_connections 40) if no other running processes use semaphores.
In other cases you will need to increase the limits. Adding the
following in /etc/sysctl.conf will be reasonable for many systems:
kern.seminfo.semmni=60kern.seminfo.semmns=1024

To serve a large number of connections (>250), you may need higher
values for the above.



So I looked around for an alternative, and found out that modern
OpenBSD releases support named POSIX semaphores (though not unnamed
ones, at least not shared unnamed ones).  What's more, it appears that
in this implementation, named semaphores don't eat open file descriptors
as they do on macOS, removing our major objection to using them.

I don't have any OpenBSD installation on hardware that I'd take very
seriously for performance testing, but some light testing with
"pgbench -S" suggests that a build with PREFERRED_SEMAPHORES=NAMED_POSIX
has just about the same performance as a build with SysV semaphores.

This all leads to the thought that maybe we should be selecting
PREFERRED_SEMAPHORES=NAMED_POSIX on OpenBSD.  At the very least,
our docs ought to recommend it as a credible alternative for
people who don't want to get into building custom kernels.

I've checked that this works back to OpenBSD 6.0, and scanning
their man pages suggests that the feature appeared in 5.5.
5.5 isn't that old (2014) so possibly people are still running
older versions, but we could easily put in version-specific
default logic similar to what's in src/template/darwin.

Thoughts?

                        regards, tom lane

[1] https://www.postgresql.org/message-id/e6ecf989-9d5a-9dc5-12de-96985b6e5a5f%40mksoft.nu

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Mikael Kjellström
Дата:
Сообщение: Re: OpenBSD versus semaphores
Следующее
От: Padam Chopra
Дата:
Сообщение: Mentoring for GCI-19