Robert Haas <robertmh...@gmail.com> writes: > On Tue, May 22, 2012 at 10:01 AM, Tom Lane <t...@sss.pgh.pa.us> wrote: >> Well, keep in mind that that action is not merely there to obtain a >> victim buffer; it is also maintaining the global LRU state (by >> decrementing the usage counts of buffers it passes over). I don't think >> you can change it to simply look only at a predetermined freelist >> without seriously compromising the overall quality of our buffer >> replacement decisions.
> The idea would be to have a background process (like bgwriter) > maintain the global LRU state and push candidate buffers onto the > freelist. Amit was trying to convince me of the same idea at PGCon, but I don't buy it. bgwriter doesn't scan the buffer array nearly fast enough to provide useful adjustment of the usage counts under load. And besides if the decrements are decoupled from the allocation requests it's no longer obvious that the algorithm is even an approximation of LRU. But the larger issue here is that if that processing is a bottleneck (which I agree it is), how does it help to force a single process to be responsible for it? Any real improvement in scalability here will need to decentralize the operation more, not less. My own thoughts about this had pointed in the direction of getting rid of the central freelist entirely, instead letting each backend run its own independent clock sweep as needed. The main problem with that is that if there's no longer any globally-visible clock sweep state, it's pretty hard to figure out what the control logic for the bgwriter should look like. Maybe it would be all right to have global variables that are just statistics counters for allocations and buffers swept over, which backends would need to spinlock for just long enough to increment the counters at the end of each buffer allocation. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers