Move PinBuffer and UnpinBuffer to atomics - Mailing list pgsql-hackers

From YUriy Zhuravlev
Subject Move PinBuffer and UnpinBuffer to atomics
Date
Msg-id 2400449.GjM57CE0Yg@dinodell
Whole thread Raw
Responses Re: Move PinBuffer and UnpinBuffer to atomics
Re: Move PinBuffer and UnpinBuffer to atomics
List pgsql-hackers
Hello hackers!

Continuing the theme: http://www.postgresql.org/message-id/3368228.mTSz6V0Jsq@dinodell

This time, we fairly rewrote  'refcount' and 'usage_count' to atomic in
PinBuffer and UnpinBuffer (but save lock for buffer flags in Unpin).

In the same time it doesn't affect to correctness of buffer manager
because that variables already have LWLock on top of them (for partition of
hashtable). If someone pinned buffer after the call StrategyGetBuffer we just
try again (in BufferAlloc).  Also in the code there is one more check before
deleting the old buffer, where changes can be rolled back. The other functions
where it is checked 'refcount' and 'usage_count' put exclusive locks.

Also stress test with 256 KB shared memory ended successfully.

Without patch we have 417523 TPS and with patch 965821 TPS for big x86 server.
All details here: https://gist.github.com/stalkerg/773a81b79a27b4d5d63f

Thank you.
--
YUriy Zhuravlev
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
Attachment

pgsql-hackers by date:

Previous
From: Etsuro Fujita
Date:
Subject: Comment update to pathnode.c
Next
From: Pavel Stehule
Date:
Subject: Re: proposal: function parse_ident