mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Use unnamed POSIX semaphores, if available, on Linux and FreeBSD.
We've had support for using unnamed POSIX semaphores instead of System V semaphores for quite some time, but it was not used by default on any platform. Since many systems have rather small limits on the number of SysV semaphores allowed, it seems desirable to switch to POSIX semaphores where they're available and don't create performance or kernel resource problems. Experimentation by me shows that unnamed POSIX semaphores are at least as good as SysV semaphores on Linux, and we previously had a report from Maksym Sobolyev that FreeBSD is significantly worse with SysV semaphores than POSIX ones. So adjust those two platforms to use unnamed POSIX semaphores, if configure can find the necessary library functions. If this goes well, we may switch other platforms as well, but it would be advisable to test them individually first. It's not currently contemplated that we'd encourage users to select a semaphore API for themselves, but anyone who wants to experiment can add PREFERRED_SEMAPHORES=UNNAMED_POSIX (or NAMED_POSIX, or SYSV) to their configure command line to do so. I also tweaked configure to report which API it's selected, mainly so that we can tell that from buildfarm reports. I did not touch the user documentation's discussion about semaphores; that will need some adjustment once the dust settles. Discussion: <8536.1475704230@sss.pgh.pa.us>
This commit is contained in:
13
configure.in
13
configure.in
@ -1939,17 +1939,30 @@ AC_SUBST(PG_CRC32C_OBJS)
|
||||
|
||||
# Select semaphore implementation type.
|
||||
if test "$PORTNAME" != "win32"; then
|
||||
if test x"$PREFERRED_SEMAPHORES" = x"NAMED_POSIX" ; then
|
||||
# Need sem_open for this
|
||||
AC_SEARCH_LIBS(sem_open, [rt pthread], [USE_NAMED_POSIX_SEMAPHORES=1])
|
||||
fi
|
||||
if test x"$PREFERRED_SEMAPHORES" = x"UNNAMED_POSIX" ; then
|
||||
# Need sem_init for this
|
||||
AC_SEARCH_LIBS(sem_init, [rt pthread], [USE_UNNAMED_POSIX_SEMAPHORES=1])
|
||||
fi
|
||||
AC_MSG_CHECKING([which semaphore API to use])
|
||||
if test x"$USE_NAMED_POSIX_SEMAPHORES" = x"1" ; then
|
||||
AC_DEFINE(USE_NAMED_POSIX_SEMAPHORES, 1, [Define to select named POSIX semaphores.])
|
||||
SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
|
||||
sematype="named POSIX"
|
||||
else
|
||||
if test x"$USE_UNNAMED_POSIX_SEMAPHORES" = x"1" ; then
|
||||
AC_DEFINE(USE_UNNAMED_POSIX_SEMAPHORES, 1, [Define to select unnamed POSIX semaphores.])
|
||||
SEMA_IMPLEMENTATION="src/backend/port/posix_sema.c"
|
||||
sematype="unnamed POSIX"
|
||||
else
|
||||
AC_DEFINE(USE_SYSV_SEMAPHORES, 1, [Define to select SysV-style semaphores.])
|
||||
SEMA_IMPLEMENTATION="src/backend/port/sysv_sema.c"
|
||||
sematype="System V"
|
||||
fi
|
||||
AC_MSG_RESULT([$sematype])
|
||||
fi
|
||||
else
|
||||
AC_DEFINE(USE_WIN32_SEMAPHORES, 1, [Define to select Win32-style semaphores.])
|
||||
|
Reference in New Issue
Block a user