From owner-freebsd-current@freebsd.org Wed Jun 22 14:26:54 2016 Return-Path: Delivered-To: freebsd-current@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 7B7FDB6963F 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 5591119D8 for ; Wed, 22 Jun 2016 14:26:54 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: by mailman.ysv.freebsd.org (Postfix) id 54E91B6963A; Wed, 22 Jun 2016 14:26:54 +0000 (UTC) Delivered-To: current@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 54806B69637 for ; Wed, 22 Jun 2016 14:26:54 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: from mail-oi0-x236.google.com (mail-oi0-x236.google.com [IPv6:2607:f8b0:4003:c06::236]) (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 184EA19D1 for ; Wed, 22 Jun 2016 14:26:54 +0000 (UTC) (envelope-from sobomax@sippysoft.com) Received: by mail-oi0-x236.google.com with SMTP id s66so24358956oif.1 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=bSsqPNW2Dt+NWPz/bkD02NUKbY478H9z9ZNUo7i1Gq9TX0DWLA1UNLR6E7IMcI9cVK MoOEZjYXZRPsFzLPkXJJajrmJ+hMhYBKydTyrv+Twv8M3fu6U7YoU//fEr6Ape/wWzuy MBMJ37z8UKNxqOk2yuNDC+Nv/OnnNPZOOklwfSeqGlchgsxs4d4NfquJ4NwSz4k92qYP 7pEgZUhgPJVVFlfqRYrKTKi8MLa/rdMPpRNtQyEQkbnFCEB1TAeZu12qjWxxSpnjOQUH uv+4WKwmNUToAwb6m6mLn3319F+TBJbM+mYSSaaVOeXiMV2c+vsPzX42Lly8pSWfDpqe 0scQ== X-Gm-Message-State: ALyK8tKTSwOnm8I+r2qiWmijZi7Zr6egWcFKDulU0GGmJR1Iqs2y7TcsI9w/ueoVmvm+shMZsaun6t4OJ2xX7onB 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-current@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Discussions about the use of FreeBSD-current 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. > >