LRU - Mailing list pgsql-patches

From Neil Conway
Subject LRU
Date
Msg-id 1106547701.22946.317.camel@localhost.localdomain
Whole thread Raw
Responses Re: LRU
List 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.

Notes:

- 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?

-Neil


Attachment

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: pg_autovacuum/Win32 Fixes
Next
From: "Dave Page"
Date:
Subject: pg_autovacuum Win32 Service startup delay