Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UN58J-00025l-NS for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Apr 2013 17:36:31 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UN58J-0005Mv-8J for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Apr 2013 17:36:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UN58I-0005Mq-JW for pgsql-hackers@postgresql.org; Tue, 02 Apr 2013 17:36:30 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UN58D-0001le-NL for pgsql-hackers@postgresql.org; Tue, 02 Apr 2013 17:36:30 +0000 Received: from intern.anarazel.de (unknown [89.204.139.252]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 562074E8003; Tue, 2 Apr 2013 19:36:22 +0200 (CEST) Date: Tue, 2 Apr 2013 19:35:10 +0200 From: Andres Freund To: Greg Stark Cc: Tom Lane , Robert Haas , Merlin Moncure , Jim Nasby , Jeff Janes , Ants Aasma , Atri Sharma , Amit Kapila , PostgreSQL-development Subject: Re: Page replacement algorithm in buffer cache Message-ID: <20130402173510.GI2415@alap2.anarazel.de> References: <515A1393.9090908@nasby.net> <3236.1364919723@sss.pgh.pa.us> <20130402163609.GG2415@alap2.anarazel.de> <3949.1364921816@sss.pgh.pa.us> 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 2013-04-02 18:26:23 +0100, Greg Stark wrote: > I'm confused by this thread. We *used* to maintain an LRU. The whole > reason for the clock-sweep algorithm is precisely to avoid maintaining > a linked list of least recently used buffers since the head of that > list is a point of contention. I don't think anybody is proposing to put the LRU back into a linked list, given the frequency of usagecount manipulations that would probably end pretty badly. What I think Robert, Tom and I are talking are talking about is putting *some* buffers with usagecount = 0 into a linked list so that when a backend requires a new page it can take one buffer from the freelist instead of a) possibly touching quite some (I have seen 4 times *every* existing header) pages to find one with usagecount = 0 b) having to write the page out itself If everything is going well that would mean only the bgwritter (or if bgfreelist or whatever) performs the clock sweep. Others take *new* pages from the freelist instead of performing part of the sweep themselves. Makes more sense? 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