BUG #14206: Switch to using POSIX semaphores on FreeBSD

From: sobomax(at)freebsd(dot)org
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #14206: Switch to using POSIX semaphores on FreeBSD
Date: 2016-06-21 19:34:12
Message-ID: 20160621193412.5792.65085@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 14206
Logged by: Maksym Sobolyev
Email address: sobomax(at)freebsd(dot)org
PostgreSQL version: 9.5.2
Operating system: FreeBSD 10.3-RELEASE amd64
Description:

Traditionally, SYSV semaphores are used to do synchronization on FreeBSD.

However, according to the analysis done by Konstantin Belousov here
https://www.kib.kiev.ua/kib/pgsql_perf_v2.0.pdf there is at the very least
some performance benefit on using POSIX semaphones instead of SYSV
semaphones in the PG running on FreeBSD host.

In addition to that performance benefit, the SYSV primitives are usually
very limited resource by default, so in order to run any more or less
significant amount of connections on your DB server you need to tweak kernel
option to increase number of those. And last but not least, SYSV primitives
once allocated need explicit removal, which might not be performed when PG
process dies or SIGKILLed. None of those is an issue with POSIX
semaphores.

We've been testing that patch on 9.1, 9.2 and 9.5 versions of the PG for few
weeks now and it performs at least as good as with old SYSV builds. We also
see drop of semaphores in use to 0 in the ipcs(1) output, so that the patch
actually does what it's supposed to do.

--- src/template/freebsd
+++ src/template/freebsd
@@ -3,3 +3,4 @@
case $host_cpu in
alpha*) CFLAGS="-O";; # alpha has problems with -O2
esac
+USE_NAMED_POSIX_SEMAPHORES=1

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2016-06-21 19:59:25 Re: BUG #14206: Switch to using POSIX semaphores on FreeBSD
Previous Message Stephen Thomas 2016-06-21 17:00:47 Re: BUG #14203: pgindent requires pg_bsd_indent 1.2, but only 1.3 available for download