Re: BufFreelistLock - Mailing list pgsql-hackers

From Jim Nasby
Subject Re: BufFreelistLock
Date
Msg-id 0449DD6E-83E9-445B-8850-8F3402C1CF56@nasby.net
Whole thread Raw
In response to Re: BufFreelistLock  (Jeff Janes <jeff.janes@gmail.com>)
Responses Re: BufFreelistLock
List pgsql-hackers
On Dec 8, 2010, at 11:44 PM, Jeff Janes wrote:
>>> For the clock sweep algorithm, I think you could access
>>> nextVictimBuffer without any type of locking.
>>
>> This is wrong, mainly because you wouldn't have any security against two
>> processes decrementing the usage count of the same buffer because they'd
>> fetched the same value of nextVictimBuffer.  That would probably happen
>> often enough to severely compromise the accuracy of the usage counts and
>> thus the accuracy of the LRU eviction behavior.  See above.
>
> Ah, I hadn't considered that.

Ideally, the clock sweep would be run by bgwriter and not individual backends. In that case it shouldn't matter much
whatthe performance of the sweep is. To do that I think we'd want the bgwriter to target there being X number of
bufferson the free list instead of (or in addition to) targeting how many dirty buffers need to be written. This would
mirrorwhat operating systems do; they strive to keep X number of pages on the free list so that when a process needs
memoryit can get it quickly. 
--
Jim C. Nasby, Database Architect                   jim@nasby.net
512.569.9461 (cell)                         http://jim.nasby.net




pgsql-hackers by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: Patch to add a primary key using an existing index
Next
From: Tom Lane
Date:
Subject: Re: initdb failure with Postgres 8.4.4