Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UN3zK-00074g-QK for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Apr 2013 16:23:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1UN3zJ-00067W-Ib for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Apr 2013 16:23:09 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UN3z3-0005vQ-SZ for pgsql-hackers@postgresql.org; Tue, 02 Apr 2013 16:22:54 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1UN3z0-0004O1-8D for pgsql-hackers@postgresql.org; Tue, 02 Apr 2013 16:22:53 +0000 Received: from intern.anarazel.de (unknown [89.204.139.252]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id 362834E8003; Tue, 2 Apr 2013 18:22:38 +0200 (CEST) Date: Tue, 2 Apr 2013 18:15:34 +0200 From: Andres Freund To: Robert Haas Cc: Merlin Moncure , Jim Nasby , Jeff Janes , Ants Aasma , Tom Lane , Atri Sharma , Greg Stark , Amit Kapila , PostgreSQL-development Subject: Re: Page replacement algorithm in buffer cache Message-ID: <20130402161534.GE2415@alap2.anarazel.de> References: <20130401210920.GC7244@alap2.anarazel.de> <515A1393.9090908@nasby.net> 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 11:54:32 -0400, Robert Haas wrote: > On Tue, Apr 2, 2013 at 11:32 AM, Merlin Moncure wrote: > > That's a very fair point, although not being able to evict pinned > > buffers is a highly mitigating aspect. Also CLOG is a different beast > > entirely -- it's much more dense (2 bits!) vs a tuple so a single page > > can a lot of high priority things. But you could be right anyways. > > > > Given that, I wouldn't feel very comfortable with forced eviction > > without knowing for sure high priority buffers were immune from that. > > Your nailing idea is maybe the ideal solution. Messing around with > > the usage_count mechanic is tempting (like raising the cap and making > > the sweeper more aggressive as it iterates), but probably really > > difficult to get right, and, hopefully, ultimately moot. > > One thought I had for fiddling with usage_count is to make it grow > additively (x = x + 1) and decay exponentially (x = x >> 1). I'm not > sure the idea is any good, but one problem with the current system is > that it's pretty trivial for a buffer to accumulate five touches, and > after that we lose all memory of what the frequency of access is, so a > pages of varying different levels of "hotness" can all have usage > count 5. This might allow a little more refinement without letting > the time to degrade the usage count get out of control. > > But, having said that, I still think the best idea is what Andres > proposed, which pretty much matches my own thoughts: the bgwriter > needs to populate the free list, so that buffer allocations don't have > to wait for linear scans of the buffer array. That's just plain too > slow. That way the usagecount should go down far more slowly which essentially makes it more granular. And I think fiddling on that level before we have a more sensible buffer acquiration implementation is pretty premature since that will change too much. 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