Re: Back-patch use of unnamed POSIX semaphores for Linux?
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2016-12-10T23:42:50Z
Lists: pgsql-hackers
Attachments
- hide-semaphore-implementation-better.patch (text/x-diff) patch
Robert Haas <robertmhaas@gmail.com> writes: > On Wed, Dec 7, 2016 at 3:12 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote: >> As things stand, it's only a configure-time choice, but I've been >> thinking that we might be well advised to make it run-time configurable. > Sure. A configure-time choice only benefits people who are compiling > from source, which as far as production is concerned is almost nobody. Attached is a proposed patch that unifies the ABI for the three Unix-y types of semaphores. I figured it wasn't worth trying to unify Windows as well, since nobody would ever be doing run-time switching between Windows and Unix code. The practical impact of this is that the sem_t or semId/semNum data is removed from the PGPROC array and placed in a separate array elsewhere in shared memory. On 64-bit Linux machines, sem_t is 64 bytes (or at least, it is on my RHEL6 box), so this change undoes the 56-byte addition that commit ecb0d20a9 caused. I think this is probably a performance win, even though it means an extra indirection to get at the sem_t, because the speed of access to the sem_t really shouldn't matter: we only touch that when we're putting a process to sleep or waking it up. Not bloating PGPROC is probably worth something, though. It would take additional work to get to being able to do run-time switching between the Unix semaphore APIs, but that work would now be localized in posix_sema.c and sysv_sema.c and would not affect code elsewhere. I think we need to do at least this much for v10, because otherwise we'll face ABI issues if an extension is compiled against code with one semaphore API choice and used with code with a different one. That didn't use to be a problem because there was really no expectation of anyone using a non-default semaphore API on any platform, but I fear it will become an issue if we don't do this. regards, tom lane
Commits
-
Make the different Unix-y semaphore implementations ABI-compatible.
- be7b2848c6d8 10.0 landed
-
Use unnamed POSIX semaphores, if available, on Linux and FreeBSD.
- ecb0d20a9d2e 10.0 cited