Re: Bgwriter strategies - Mailing list pgsql-hackers

From Greg Smith
Subject Re: Bgwriter strategies
Date
Msg-id Pine.GSO.4.64.0707061442170.22467@westnet.com
Whole thread Raw
In response to Re: Bgwriter strategies  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Fri, 6 Jul 2007, Tom Lane wrote:

> The problem is that it'd be very hard to track how far ahead of the
> recycling sweep hand we are, because that number has to be measured
> in usage-count-zero pages.  I see no good way to know how many of the
> pages we scanned before have been touched (and given nonzero usage
> counts) unless we rescan them.

I've actually been working on how to address that specific problem without 
expressly tracking the contents of the buffer cache.  When the background 
writer is called, it finds out how many buffers were allocated and how far 
the sweep point moved since the last call.  From that, you can calculate 
how many buffers on average need to be scanned per allocation, which tells 
you something about the recently encountered density of 0-usage count 
buffers.  My thought was to use that as an input to the computation for 
how far ahead to stay.

> I've been doing moving averages for years and years, and I find that the
> multiplication approach works at least as well as explicitly storing the
> last K observations.  It takes a lot less storage and arithmetic too.

I was simplifying the description just to comment on the range for K; I 
was using a multiplication approach for the computation.

--
* Greg Smith gsmith@gregsmith.com http://www.gregsmith.com Baltimore, MD


pgsql-hackers by date:

Previous
From: Jan Wieck
Date:
Subject: Re: usleep feature for pgbench
Next
From: Alvaro Herrera
Date:
Subject: Re: Still recommending daily vacuum...