Buffer manager (was Re: relcache refcount) - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Buffer manager (was Re: relcache refcount)
Date
Msg-id 20040524041440.GA2668@dcc.uchile.cl
Whole thread Raw
In response to Re: relcache refcount  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On Thu, May 13, 2004 at 09:43:42AM -0400, Tom Lane wrote:

> BTW, what are your plans for state saving/reversion for the lock manager
> and buffer manager?

Ok, I have skimmed through the buffer manager code.  At first I thought
I'd have to set something up in shared memory for this, but then I
noticed that every backend keeps a local reference count, and modifies
the shared counter only when the local one raises from zero, or drops to
zero.

Also, the number of buffers does not change while the server is running.

So I see two ways of handling this:

1. Keep an array of local refcounts for all buffers, for each subtrans.
At subtrans start, a new array is allocated and filled with current
local refcounts.  At subtrans abort, we check if any count would go to
zero while restoring; if so, decrement the shared counter.  At subtrans
commit, drop the saved array.

The problem with this approach is that we allocate a large array which
likely will be almost full of zeros.

2. Keep a more elaborate struct, where each buffer get its local count
saved only if its nonzero.  Thus we don't have to allocate a large
amount of memory.

Comments?  Opinions?  Which one do you think is better?  Any completely
different idea?

-- 
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Coge la flor que hoy nace alegre, ufana. ¿Quién sabe si nacera otra mañana?"



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Unicode upper/lower solution proposal
Next
From: Fabien COELHO
Date:
Subject: Re: Latest requests from IRC