pgsql: Reduce ProcArrayLock contention by removing backends in batches.

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Reduce ProcArrayLock contention by removing backends in batches.
Date: 2015-08-06 16:05:52
Message-ID: E1ZNNg0-0003hW-Kz@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Reduce ProcArrayLock contention by removing backends in batches.

When a write transaction commits, it must clear its XID advertised via
the ProcArray, which requires that we hold ProcArrayLock in exclusive
mode in order to prevent concurrent processes running GetSnapshotData
from seeing inconsistent results. When many processes try to commit
at once, ProcArrayLock must change hands repeatedly, with each
concurrent process trying to commit waking up to acquire the lock in
turn. To make things more efficient, when more than one backend is
trying to commit a write transaction at the same time, have just one
of them acquire ProcArrayLock in exclusive mode and clear the XIDs of
all processes in the group. Benchmarking reveals that this is much
more efficient at very high client counts.

Amit Kapila, heavily revised by me, with some review also from Pavan
Deolasee.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/0e141c0fbb211bdd23783afa731e3eef95c9ad7a

Modified Files
--------------
src/backend/access/transam/README | 3 +
src/backend/storage/ipc/procarray.c | 166 ++++++++++++++++++++++++++++++-----
src/backend/storage/lmgr/proc.c | 5 ++
src/include/storage/proc.h | 12 +++
4 files changed, 166 insertions(+), 20 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2015-08-06 17:46:54 pgsql: Fix incorrect calculation in shm_mq_receive.
Previous Message Kevin Grittner 2015-08-06 15:51:09 pgsql: Fix `make installcheck` for serializable transactions.