From 79ccd7cbd5ca44bee0191d12e9e65abf702899e7 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Mon, 21 Aug 2017 14:43:00 -0400 Subject: pg_prewarm: Add automatic prewarm feature. Periodically while the server is running, and at shutdown, write out a list of blocks in shared buffers. When the server reaches consistency -- unfortunatey, we can't do it before that point without breaking things -- reload those blocks into any still-unused shared buffers. Mithun Cy and Robert Haas, reviewed and tested by Beena Emerson, Amit Kapila, Jim Nasby, and Rafia Sabih. Discussion: http://postgr.es/m/CAD__OugubOs1Vy7kgF6xTjmEqTR4CrGAv8w+ZbaY_+MZeitukw@mail.gmail.com --- src/backend/storage/buffer/freelist.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/backend/storage/buffer/freelist.c') diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 9d8ae6ae8e1..f033323cfff 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -168,6 +168,23 @@ ClockSweepTick(void) return victim; } +/* + * have_free_buffer -- a lockless check to see if there is a free buffer in + * buffer pool. + * + * If the result is true that will become stale once free buffers are moved out + * by other operations, so the caller who strictly want to use a free buffer + * should not call this. + */ +bool +have_free_buffer() +{ + if (StrategyControl->firstFreeBuffer >= 0) + return true; + else + return false; +} + /* * StrategyGetBuffer * -- cgit v1.2.3