Re: Bgwriter strategies

From: Greg Smith <gsmith(at)gregsmith(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bgwriter strategies
Date: 2007-07-06 18:57:14
Message-ID: Pine.GSO.4.64.0707061442170.22467@westnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)gregsmith(dot)com http://www.gregsmith.com Baltimore, MD

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2007-07-06 19:04:27 Re: Still recommending daily vacuum...
Previous Message Jan Wieck 2007-07-06 18:35:29 Re: usleep feature for pgbench