Re: OpenBSD versus semaphores

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Mikael Kjellström <mikael(dot)kjellstrom(at)gmail(dot)com>, Pierre-Emmanuel André <pea(at)openbsd(dot)org>
Subject: Re: OpenBSD versus semaphores
Date: 2019-01-08 07:40:26
Message-ID: 30870.1546933226@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com> writes:
> On Tue, Jan 8, 2019 at 7:14 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>> 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.

> No OpenBSD here, but I was curious enough to peek at their
> implementation. Like others, they create a tiny file under /tmp for
> each one, mmap() and close the fd straight away.

Oh, yeah, I can see a bunch of tiny mappings with procmap. I wonder
whether that scales any better than an open FD per semaphore, when
it comes to forking a bunch of child processes that will inherit
all those mappings or FDs. I've not tried to benchmark child process
launch as such --- as I said, I'm not running this on hardware that
would support serious benchmarking.

BTW, I just finished finding out that recent NetBSD (8.99.25) has
working code paths for *both* named and unnamed POSIX semaphores.
However, it appears that both code paths involve an open FD per
semaphore, so it's likely not something we want to recommend using.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2019-01-08 07:42:35 Re: [Sender Address Forgery]Re: error message when subscription target is a partitioned table
Previous Message Kyotaro HORIGUCHI 2019-01-08 07:26:38 Re: Improve selectivity estimate for range queries