Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X2FF4-00008B-Mv for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Jul 2014 07:46:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X2FF3-0004rT-Rg for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Jul 2014 07:46:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X2FF2-0004rJ-Lt for pgsql-hackers@postgresql.org; Wed, 02 Jul 2014 07:46:08 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X2FEy-0007Za-VQ for pgsql-hackers@postgresql.org; Wed, 02 Jul 2014 07:46:07 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id 7F207500002; Wed, 2 Jul 2014 09:46:04 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-5.1 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from anarazel.de (p5DDC581C.dip0.t-ipconnect.de [93.220.88.28]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 5EDAB500001; Wed, 2 Jul 2014 09:46:01 +0200 (CEST) Received: by anarazel.de (Postfix, from userid 1000) id D51CD1003CC; Wed, 2 Jul 2014 09:46:00 +0200 (CEST) Date: Wed, 2 Jul 2014 09:46:00 +0200 From: Andres Freund To: Ants Aasma Cc: Robert Haas , Tom Lane , Peter Geoghegan , Pg Hackers Subject: Re: better atomics - v0.5 Message-ID: <20140702074600.GH21169@awork2.anarazel.de> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 2014-07-02 09:27:52 +0300, Ants Aasma wrote: > On Fri, Jun 27, 2014 at 9:00 PM, Andres Freund wrote: > > Imagine the situation for the buffer header spinlock which is one of the > > bigger performance issues atm. We could aim to replace all usages of > > that with clever and complicated logic, but it's hard. > > > > The IMO reasonable (and prototyped) way to do it is to make the common > > paths lockless, but fall back to the spinlock for the more complicated > > situations. For the buffer header that means that pin/unpin and buffer > > lookup are lockless, but IO and changing the identity of a buffer still > > require the spinlock. My attempts to avoid the latter basically required > > a buffer header specific reimplementation of spinlocks. > > There is a 2010 paper [1] that demonstrates a fully non-blocking > approach to buffer management using the same generalized clock > algorithm that PostgreSQL has. The site also has an implementation for > Apache Derby. You may find some interesting ideas in there. > > [1] http://code.google.com/p/derby-nb/source/browse/trunk/derby-nb/ICDE10_conf_full_409.pdf Interesting. Thanks for the link. I think I had pretty much all the parts they described lockless as well (excluding the buffer mapping hashtable itself, which they didn't focus on either), it was just operations like replacing a dirty victim buffer where I fell back to the spinlock. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers