From owner-freebsd-performance@freebsd.org Wed Jun 22 14:26:54 2016 Return-Path: Delivered-To: freebsd-performance@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 99D15B69642 for ; Wed, 22 Jun 2016 14:26:54 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id 73DE519DC for ; Wed, 22 Jun 2016 14:26:54 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: by mailman.ysv.freebsd.org (Postfix) id 6FD69B6963D; Wed, 22 Jun 2016 14:26:54 +0000 (UTC) Delivered-To: performance@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6D2B8B6963C for ; Wed, 22 Jun 2016 14:26:54 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: from mail-oi0-x22e.google.com (mail-oi0-x22e.google.com [IPv6:2607:f8b0:4003:c06::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2D0BF19D6 for ; Wed, 22 Jun 2016 14:26:54 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: by mail-oi0-x22e.google.com with SMTP id f189so24334284oig.3 for ; Wed, 22 Jun 2016 07:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sippysoft-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=r/NmRzpGThk1aVRAcTUeMQLapWNn/JvOvb9Ir6Ec4Lg=; b=uCdt91Dec+M7FIguu2hYXxZJ9WFe11ak9weMMYHgr09dYXXTHLRjgBW6VAMpDk6d93 YixkRSoTpNoQuc9TR/kMS/eZlWrmdKhv3XHkUT3315CN730RuILXkuV7x8UHyrRLrS+9 Xbsa5rXmqfXI8DCJhfLaDARPnFUFeMHEhb7jp0sCusgPRxyviGpHD1Y0cZ9DSs7zz2kL uJkTc8GzXT49UHJARxPE9Gi6lSjVtIfKQJ8QvwxKoDQAaNIzbmQ33J2/NJZjdhTLnwIS LTGV3uqngQl7MJPaMlF5HFHewitJAlkyVUOHHJ8Uosy7zMgF6LUvZA3aZ6qzh651U/e5 gHtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=r/NmRzpGThk1aVRAcTUeMQLapWNn/JvOvb9Ir6Ec4Lg=; b=mWjAgha9xuoMhoYs2v0mxsMAKIWSxrBZa5ZlVHk/vM5zbIDjjHoT+RR3v1ZxBIYAPg 5H8PUFFQEgPZYaXed2WkSjj/JUwJ1SPMSEpZp0XxW6T9NZ0nczv7T201kxCFITUeZI0S fi0oRokfYq305lWA+Kfaqm+bImhOK1mxoVkwF97fbhex/1lHt4K2bHQKQbLdZ5Ywa3jL M0QUc8n5Q2xug8mnjDm8Ib4tRiuWOeAmXf0EvV5iGp9s+DgrdvIkVrdf1jUnQ9ftyxNF PhNe6OKiAJlcmbZjt4P8zXwawB08QPgHIknCzFvQfSikqHkQUEVBnGTAI8MvIF1175Nb LwwQ== X-Gm-Message-State: ALyK8tLMfS5qFvvdU3MLuyV18UmdLlXKuO+dsfGjZ+7C3IFs+eHmQF3VIz2pzh15QOHdu1FBAeo6/tlhWwTLXHom X-Received: by 10.202.231.198 with SMTP id e189mr1715841oih.3.1466605613413; Wed, 22 Jun 2016 07:26:53 -0700 (PDT) MIME-Version: 1.0 Sender: sobomax@sippysoft.com Received: by 10.157.41.209 with HTTP; Wed, 22 Jun 2016 07:26:52 -0700 (PDT) In-Reply-To: <20160622100241.GM38613@kib.kiev.ua> References: <20140627125613.GT93733@kib.kiev.ua> <1603235.2ShtoCfSqO@ralph.baldwin.cx> <20160622100241.GM38613@kib.kiev.ua> From: Maxim Sobolev Date: Wed, 22 Jun 2016 07:26:52 -0700 X-Google-Sender-Auth: GEhz5HWzcNo5tUqTMHS36sfjGuc Message-ID: Subject: Re: PostgreSQL performance on FreeBSD To: Konstantin Belousov Cc: John Baldwin , Adrian Chadd , Alan Somers , Alan Cox , Alan Cox , freebsd-current , performance@freebsd.org, "current@freebsd.org" Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.22 X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jun 2016 14:26:54 -0000 Konstantin, Not if you do sem_unlink() immediately, AFAIK. And that's what PG does. So the window of opportunity for the leakage is quite small, much smaller than for SYSV primitives. Sorry for missing your status update message, I've missed it somehow. ---- mySem = sem_open(semname, O_CREAT | O_EXCL, (mode_t) IPCProtection, (unsigned) 1); #ifdef SEM_FAILED if (mySem != (sem_t *) SEM_FAILED) break; #else if (mySem != (sem_t *) (-1)) break; #endif /* Loop if error indicates a collision */ if (errno == EEXIST || errno == EACCES || errno == EINTR) continue; /* * Else complain and abort */ elog(FATAL, "sem_open(\"%s\") failed: %m", semname); } /* * Unlink the semaphore immediately, so it can't be accessed externally. * This also ensures that it will go away if we crash. */ sem_unlink(semname); return mySem; ---- -Max On Wed, Jun 22, 2016 at 3:02 AM, Konstantin Belousov wrote: > On Tue, Jun 21, 2016 at 12:48:00PM -0700, Maxim Sobolev wrote: > > Thanks, Konstantin for the great work, we are definitely looking forward > to > > get all those improvements to be part of the default FreeBSD kernel/port. > > Would be nice if you can post an update some day later as to what's > > integrated and what's not. > I did posted the update several days earlier. Since you replying to this > thread, it would be not unreasonable to read recent messages that were > sent. > > > > > Just in case, I've opened #14206 with PG to switch us to using POSIX > > semaphores by default. Apart from the mentioned performance benefits, > SYSV > > semaphores are PITA to deal with as they come in very limited quantities > by > > default. Also they might stay around if PG dies/gets nuked and prevent it > > from starting again due to overflow. We've got some quite ugly code to > > clean up those using ipcrm(1) in our build scripts to deal with just > that. > > I am happy that code could be retired now. > > Named semaphores also stuck around if processes are killed without cleanup. > >