bufmgr: Add one-entry cache for private refcount master github/master
authorAndres Freund <[email protected]>
Sun, 14 Dec 2025 18:09:43 +0000 (13:09 -0500)
committerAndres Freund <[email protected]>
Sun, 14 Dec 2025 18:09:43 +0000 (13:09 -0500)
commit30df61990c67f0cf7450e36c1e038d513960f148
treee068a237f0d522b2269fe9ee86494c38c65b57f8
parentedbaaea0a95ef1c32ffe8aa62e1556588c7a714b
bufmgr: Add one-entry cache for private refcount

The private refcount entry for a buffer is often looked up repeatedly for the
same buffer, e.g. to pin and then unpin a buffer. Benchmarking shows that it's
worthwhile to have a one-entry cache for that case. With that cache in place,
it's worth splitting GetPrivateRefCountEntry() into a small inline
portion (for the cache hit case) and an out-of-line helper for the rest.

This is helpful for some workloads today, but becomes more important in an
upcoming patch that will utilize the private refcount infrastructure to also
store whether the buffer is currently locked, as that increases the rate of
lookups substantially.

Reviewed-by: Melanie Plageman <[email protected]>
Discussion: https://postgr.es/m/6rgb2nvhyvnszz4ul3wfzlf5rheb2kkwrglthnna7qhe24onwr@vw27225tkyar
src/backend/storage/buffer/bufmgr.c