pgsql: Avoid acquiring spinlock when checking if recovery has finished,

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Avoid acquiring spinlock when checking if recovery has finished,
Date: 2013-11-22 11:10:22
Message-ID: E1Vjocw-0000hN-Ek@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid acquiring spinlock when checking if recovery has finished, for speed.

RecoveryIsInProgress() can be called very frequently. During normal
operation, it just checks a backend-local variable and returns quickly,
but during hot standby, it checks a spinlock-protected shared variable.
Those spinlock acquisitions can become a point of contention on a busy
hot standby system.

Replace the spinlock acquisition with a memory barrier.

Per discussion with Andres Freund, Ants Aasma and Merlin Moncure.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/1a3d104475ce01326fc00601ed66ac4d658e37e5

Modified Files
--------------
src/backend/access/transam/xlog.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2013-11-22 12:59:50 pgsql: Fix Hot-Standby initialization of clog and subtrans.
Previous Message Peter Eisentraut 2013-11-22 02:53:41 pgsql: Tweak streamutil.c further to avoid scan-build warning