| From: | Andres Freund <andres(at)anarazel(dot)de> |
|---|---|
| To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
| Cc: | Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
| Subject: | Re: Let's drop support for named POSIX semaphores |
| Date: | 2026-10-26 16:59:24 |
| Message-ID: | mt5ox4lazoetezhmsnjqcxmzthfa2dvsag5q5msgydx5ylnevv@kfoiufekhj24 |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On 2026-10-26 11:42:56 -0400, Tom Lane wrote:
> So I think the direction we'd have to go in to make that happen is to
> replace all the semaphore stuff with futexes or some other low-level
> primitive, as Munro speculated about in one of the threads I cited.
Agreed, that's the right direction. We really aren't using semaphores in a way
that benefits from them being semaphores. In fact, we have to fix up the
semaphore counters in a bunch of places that would not need such complication
with a better primitive.
FWIW, I recalled Thomas posting patches for macos futexes before. I didn't
immediately find them, but did quickly find the branch that implements futexes
on macos:
https://github.com/macdice/postgres/commits/pg_futex/
https://github.com/macdice/postgres/commit/bf2ceb73fe8a48ece981a82ef103284e5dfc0a54
Given that, as Thomas notes in [1], macos finally documents the futex APIs,
that seems like the obvious way forward.
I also found an older branch of Thomas' that abstracts futexes across a number
of platforms [2] and then implements semaphores on top of those futexes.
It's *really* annoying that window's WaitOnAddress() equivalent explicitly
requires the waiter and waker to be threads in the same process :(.
E.g. lwlocks would be faster *and* the code would be simpler if futexes could
be used everywhere.
Greetings,
Andres
[1] https://www.postgresql.org/message-id/CA%2BhUKGKAPR%3DNXxMTCmEomCUpq%2BmrPLDVyfVa4bKZqfDjwyzD7Q%40mail.gmail.com
[2] https://github.com/macdice/postgres/commits/pg_futex/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-10-26 17:02:26 | Re: [PG19] A canceled notify read leaves the NOTIFY queue stuck |
| Previous Message | Pavel Stehule | 2026-10-26 16:58:55 | Re: PL/pgSQL: fix validation of anycompatiblemultirange |