pgsql: Fix various shortcomings of the new PrivateRefCount infrastructu

Поиск
Список
Период
Сортировка
От Andres Freund
Тема pgsql: Fix various shortcomings of the new PrivateRefCount infrastructu
Дата
Msg-id E1YDLy1-0004QY-NE@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix various shortcomings of the new PrivateRefCount infrastructure.

As noted by Tom Lane the improvements in 4b4b680c3d6 had the problem
that in some situations we searched, entered and modified entries in
the private refcount hash while holding a spinlock. I had tried to
keep the logic entirely local to PinBuffer_Locked(), but that's not
really possible given it's called with a spinlock held...

Besides being disadvantageous from a performance point of view, this
also has problems with error handling safety. If we failed inserting
an entry into the hashtable due to an out of memory error, we'd error
out with a held spinlock. Not good.

Change the way private refcounts are manipulated: Before a buffer can
be tracked an entry has to be reserved using
ReservePrivateRefCountEntry(); then, if a entry is not found using
GetPrivateRefCountEntry(), it can be entered with
NewPrivateRefCountEntry().

Also take advantage of the fact that PinBuffer_Locked() currently is
never called for buffers that already have been pinned by the current
backend and don't search the private refcount entries for preexisting
local pins. That results in a small, but measurable, performance
improvement.

Additionally make ReleaseBuffer() always call UnpinBuffer() for shared
buffers. That avoids duplicating work in an eventual UnpinBuffer()
call that already has been done in ReleaseBuffer() and also saves some
code.

Per discussion with Tom Lane.

Discussion: 15028.1418772313@sss.pgh.pa.us

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/2d115e47c861878669ba0814b3d97a4e4c347e8b

Modified Files
--------------
src/backend/storage/buffer/bufmgr.c |  359 +++++++++++++++++++----------------
1 file changed, 195 insertions(+), 164 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: pgsql: Use abbreviated keys for faster sorting of text datums.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Adjust "pgstat wait timeout" message to be a translatable LOG me