Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFimX-0000pg-8C for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Jun 2016 14:05:29 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1bFimW-0006R8-IY for pgsql-bugs@arkaria.postgresql.org; Wed, 22 Jun 2016 14:05:28 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1bFexQ-00086i-TU for pgsql-bugs@postgresql.org; Wed, 22 Jun 2016 10:00:29 +0000 Received: from kib.kiev.ua ([2001:470:d5e7:1::1]) by makus.postgresql.org with esmtps (TLS1.0:DHE_RSA_CAMELLIA_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1bFexN-0003n2-0I for pgsql-bugs@postgresql.org; Wed, 22 Jun 2016 10:00:27 +0000 Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id u5MA0E7q017573 (version=TLSv1 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Wed, 22 Jun 2016 13:00:15 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua u5MA0E7q017573 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id u5MA0EWo017571; Wed, 22 Jun 2016 13:00:14 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 22 Jun 2016 13:00:14 +0300 From: Konstantin Belousov To: Tom Lane Cc: Maxim Sobolev , pgsql-bugs@postgresql.org Subject: Re: BUG #14206: Switch to using POSIX semaphores on FreeBSD Message-ID: <20160622100014.GL38613@kib.kiev.ua> References: <20160621193412.5792.65085@wrigleys.postgresql.org> <16860.1466539165@sss.pgh.pa.us> <18145.1466541362@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <18145.1466541362@sss.pgh.pa.us> User-Agent: Mutt/1.6.1 (2016-04-27) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home X-Pg-Spam-Score: -0.3 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On Tue, Jun 21, 2016 at 04:36:02PM -0400, Tom Lane wrote: > Maxim Sobolev writes: > > Tom, thanks for looking at it so promptly. I am adding kib@ into the > > discussion. Perhaps he would comment on the SYSV vs. POSIX in FreeBSD and > > named vs. unnamed. > > BTW, I trawled our archives and found this thread concerning the switch > from POSIX to SYSV on OS X: > > https://www.postgresql.org/message-id/flat/3830CBEB-F8CE-4EBC-BE16-A415E78A4CBC%40apple.com > > I'm not sure what you were using to decide that POSIX semaphores were > okay, but the points in that thread about pgbench not being a very > good test case remain relevant. > > > As far as I can tell, the sem_init(3) interface is present in the FreeBSD > > 10.3, so maybe we can use those instead? > > If that seems like a competitive alternative for you, it'd be nice to have > a platform where we use unnamed POSIX semaphores by default. I'm a little > worried about whether that code has suffered bit-rot, since it's been > sitting there basically unused for so long. On FreeBSD, there is no practical difference in the resource consumption for named vs. unnamed semaphore. I mean that after sem_open(3) call, an open file descriptor is not kept in the process fd table. The semaphore is represented by the mmaped page, libc+kernel operate solely on the page content and use umtx(2) to implement counted semaphore. In other words, no, there is no additional overhead of starting connection when using either named or unnamed (sem_init(3)) POSIX semaphores on FreeBSD, and there is no any open files overhead. That said, the problem with the SysV semaphores is that API allows operations on arbitrary sets of the semaphores. Unless some unordinary and complex measures are taken, implementation has to use global internal lock to synchronize semop(2). This is what I noted in the paper. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs