forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2d115e4
committed
Fix various shortcomings of the new PrivateRefCount infrastructure.
As noted by Tom Lane the improvements in4b4b680 had the problemthat in some situations we searched, entered and modified entries inthe private refcount hash while holding a spinlock. I had tried tokeep the logic entirely local to PinBuffer_Locked(), but that's notreally possible given it's called with a spinlock held...Besides being disadvantageous from a performance point of view, thisalso has problems with error handling safety. If we failed insertingan entry into the hashtable due to an out of memory error, we'd errorout with a held spinlock. Not good.Change the way private refcounts are manipulated: Before a buffer canbe tracked an entry has to be reserved usingReservePrivateRefCountEntry(); then, if a entry is not found usingGetPrivateRefCountEntry(), it can be entered withNewPrivateRefCountEntry().Also take advantage of the fact that PinBuffer_Locked() currently isnever called for buffers that already have been pinned by the currentbackend and don't search the private refcount entries for preexistinglocal pins. That results in a small, but measurable, performanceimprovement.Additionally make ReleaseBuffer() always call UnpinBuffer() for sharedbuffers. That avoids duplicating work in an eventual UnpinBuffer()call that already has been done in ReleaseBuffer() and also saves somecode.Per discussion with Tom Lane.Discussion: 15028.1418772313@sss.pgh.pa.us1 parent4ea51cd commit2d115e4
1 file changed
+195
-164
lines changed0 commit comments
Comments
(0)