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/
