]> granicus.if.org Git - postgresql/commit
Pad semaphores to avoid false sharing.
authorThomas Munro <tmunro@postgresql.org>
Tue, 24 Jul 2018 22:57:52 +0000 (10:57 +1200)
committerThomas Munro <tmunro@postgresql.org>
Tue, 24 Jul 2018 23:00:29 +0000 (11:00 +1200)
commit2d3067595299d2ac1f29bbc26a83a99d59b33d4e
tree14349ff1232e599931ca5b148fb22f820d1955c9
parent487bcc6ea6757a563fff188a9551e011d85b6caa
Pad semaphores to avoid false sharing.

In a USE_UNNAMED_SEMAPHORES build, the default on Linux and FreeBSD
since commit ecb0d20a, we have an array of sem_t objects.  This
turned out to reduce performance compared to the previous default
USE_SYSV_SEMAPHORES on an 8 socket system.  Testing showed that the
lost performance could be regained by padding the array elements so
that they have their own cache lines.  This matches what we do for
similar hot arrays (see LWLockPadded, WALInsertLockPadded).

Back-patch to 10, where unnamed semaphores were adopted as the default
semaphore interface on those operating systems.

Author: Thomas Munro
Reviewed-by: Andres Freund
Reported-by: Mithun Cy
Tested-by: Mithun Cy, Tom Lane, Thomas Munro
Discussion: https://postgr.es/m/CAD__OugYDM3O%2BdyZnnZSbJprSfsGFJcQ1R%3De59T3hcLmDug4_w%40mail.gmail.com
src/backend/port/posix_sema.c