strategyfreebuffer.v1.patch
text/x-patch
Filename: strategyfreebuffer.v1.patch
Type: text/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
Series: patch v1
| File | + | − |
|---|---|---|
| src/backend/storage/buffer/freelist.c | 11 | 2 |
diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c
index 3e62448..af7215f 100644
--- a/src/backend/storage/buffer/freelist.c
+++ b/src/backend/storage/buffer/freelist.c
@@ -218,12 +218,21 @@ StrategyGetBuffer(BufferAccessStrategy strategy, bool *lock_held)
}
/*
- * StrategyFreeBuffer: put a buffer on the freelist
+ * StrategyFreeBuffer: put a buffer on the freelist, unless we're busy
*/
void
StrategyFreeBuffer(volatile BufferDesc *buf)
{
- LWLockAcquire(BufFreelistLock, LW_EXCLUSIVE);
+ /*
+ * The buffer is already invalidated and is now an allocation target.
+ * Adding buffers back onto the freelist is an optimisation only,
+ * so we can decide to skip this step if the lock is busy.
+ * This improves the speed of dropping indexes and tables on a busy system.
+ * If the system is busy the newly invalidated buffers will be reallocated
+ * within one clock sweep.
+ */
+ if (!LWLockConditionalAcquire(BufFreelistLock, LW_EXCLUSIVE))
+ return;
/*
* It is possible that we are told to put something in the freelist that