Re: Page replacement algorithm in buffer cache - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: Page replacement algorithm in buffer cache
Date
Msg-id 006201ce26c2$41bd77d0$c5386770$@kapila@huawei.com
Whole thread Raw
In response to Page replacement algorithm in buffer cache  (Atri Sharma <atri.jiit@gmail.com>)
List pgsql-hackers
On Friday, March 22, 2013 10:22 AM Atri Sharma wrote:
> Hello all,
> 
> Sorry if this is a naive question.
> 
> I was going through Greg Smith's slides on buffer
> cache(http://www.westnet.com/~gsmith/content/postgresql/InsideBufferCac
> he.pdf).
> When going through the page replacement algorithm that we use i.e.
> clocksweep algorithm, I felt a potential problem in our current
> system.
> 
> Specifically, when a new entry is allocated in the buffer, it's
> USAGE_COUNT is set to 1. On each sweep of the algorithm, the
> USAGE_COUNT is decremented and an entry whose  USAGE_COUNT becomes
> zero is replaced.

Yes, it is replaced but in the next clock sweep pass, not immediately after
making 0.
So till the time of next pass if nobody accesses the buffer and all other
buffers have higher count, it can be replaced.
Also the buffer, it has returned for which the usage count becomes 1, it
will come to reduce the usage count only in next pass.
So in whole, I think it needs 2 passes for a freshly returned buffer to be
re-used incase no one uses it again.

With Regards,
Amit Kapila.




pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Proposal for Allow postgresql.conf values to be changed via SQL [review]
Next
From: Atri Sharma
Date:
Subject: Re: Page replacement algorithm in buffer cache