pgsql: Avoid the use of a separate spinlock to protect a LWLock's wait

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Avoid the use of a separate spinlock to protect a LWLock's wait
Date: 2016-04-11 03:12:51
Message-ID: E1apSHT-0007xK-Bl@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid the use of a separate spinlock to protect a LWLock's wait queue.

Previously we used a spinlock, in adition to the atomically manipulated
->state field, to protect the wait queue. But it's pretty simple to
instead perform the locking using a flag in state.

Due to 6150a1b0 BufferDescs, on platforms (like PPC) with > 1 byte
spinlocks, increased their size above 64byte. As 64 bytes are the size
we pad allocated BufferDescs to, this can increase false sharing;
causing performance problems in turn. Together with the previous commit
this reduces the size to <= 64 bytes on all common platforms.

Author: Andres Freund
Discussion: CAA4eK1+ZeB8PMwwktf+3bRS0Pt4Ux6Rs6Aom0uip8c6shJWmyg(at)mail(dot)gmail(dot)com
20160327121858(dot)zrmrjegmji2ymnvr(at)alap3(dot)anarazel(dot)de

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/008608b9d51061b1f598c197477b3dc7be9c4a64

Modified Files
--------------
src/backend/storage/lmgr/lwlock.c | 189 ++++++++++++++++++++++----------------
src/include/storage/lwlock.h | 6 +-
2 files changed, 113 insertions(+), 82 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2016-04-11 03:16:24 pgsql: Fix access-to-already-freed-memory issue in plpython's error han
Previous Message Andres Freund 2016-04-10 23:08:56 Re: [COMMITTERS] pgsql: Move each SLRU's lwlocks to a separate tranche.