Use UnlockReleaseBuffer() in more places
Andres Freund <andres@anarazel.de>
Use UnlockReleaseBuffer() in more places An upcoming commit will make UnlockReleaseBuffer() considerably faster and more scalable than doing LockBuffer(BUFFER_LOCK_UNLOCK); ReleaseBuffer();. But it's a small performance benefit even as-is. Most of the callsites changed in this patch are not performance sensitive, however some, like the nbtree ones, are in critical paths. This patch changes all the easily convertible places over to UnlockReleaseBuffer() mainly because I needed to check all of them anyway, and reducing cases where the operations are done separately makes the checking easier. Reviewed-by: Melanie Plageman <melanieplageman@gmail.com> Discussion: https://postgr.es/m/5ubipyssiju5twkb7zgqwdr7q2vhpkpmuelxfpanetlk6ofnop@hvxb4g2amb2d
Files
| Path | Change | +/− |
|---|---|---|
| contrib/amcheck/verify_gin.c | modified | +2 −4 |
| contrib/pageinspect/rawpage.c | modified | +1 −2 |
| src/backend/access/heap/heapam.c | modified | +2 −4 |
| src/backend/access/heap/hio.c | modified | +4 −3 |
| src/backend/access/nbtree/nbtpage.c | modified | +29 −6 |
| src/backend/storage/buffer/bufmgr.c | modified | +1 −2 |
| src/backend/storage/freespace/freespace.c | modified | +1 −2 |
| src/test/modules/test_aio/test_aio.c | modified | +2 −5 |
Discussion
- Buffer locking is special (hints, checksums, AIO writes) 120 messages · 2025-08-22 → 2026-04-03