From: Neil Conway <neilc(at)samurai(dot)com>
To: pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: LRU
Date: 2005-01-24 06:21:41
Message-ID: 1106547701.22946.317.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-patches

This patch replaces ARC with LRU in current sources. It is intended as a
short-term measure to replace ARC; in the longer run, we should probably
look at implementing a more effective replacement policy that is not
patent encumbered.


- WIP; it has survived a couple hundred thousand pgbench transactions
and repeated regression tests, but I still want to do another code
review or two.

- It doesn't implement sequential scan activity hints, so it probably
suffers from sequential flooding. This may be something we'll want to
fix in the 8.0 timeframe, I'm not sure.

- The LRU list is maintained via links in the BufferDesc structure, as
was the case in 7.4 and earlier. In general the patch ought to be pretty
similar to the 7.4 code, although I've taken the opportunity to (IMHO)
simplify some things (the freelist is no longer circular, for instance).

- One major behavioral change effects the bgwriter. In order to return
pages in LRU order, we can _only_ scan the free list (since we don't
bother to maintain a list of pinned buffers sorted by the recency of
last access). I think this is actually a good idea: I'm not sure why the
bgwriter should be writing out pinned buffers anyway, since it increases
the likelihood that it will interfere with normal system activity, and a
pinned buffer is pretty likely to be re-dirtied later on. So the
bgwriter has been changed to only examine unpinned buffers.

As a result of that, there is no easy way to say "flush at most n% of
the dirty buffers", because the bgwriter no longer considers all the
dirty buffers. So I've removed bgwriter_percent for now. Advice on the
best way to resolve this situation would be welcome -- should we keep
bgwriter_percent in one form or another, redefine bgwriter_maxpages
according to the December discussion, or ...?

- This patch has a lot of assertions -- I'll disable the more expensive
and unnecessary ones once the patch is closer to being finished.

- Added BufferGetBufferDescriptor(); I'm not sure if it is notationally
cleaner to use this rather than manually looking up entries in the
BufferDescriptor array. Also, at present BufferGetBufferDescriptor()
doesn't handle local buffers; to make it do that, we'd need to
doubly-evaluate the macro argument. Comments?


Attachment Content-Type Size
bufmgr_lru-7.patch text/x-patch 78.5 KB


  • Re: LRU at 2005-01-24 22:39:18 from Tom Lane

Browse pgsql-patches by date

  From Date Subject
Next Message Jonah H. Harris 2005-01-24 15:28:09 Re: Much Ado About COUNT(*)
Previous Message Bruce Momjian 2005-01-24 00:19:10 Re: pg_autovacuum/Win32 Fixes