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