pgsql: Improve LWLock scalability.

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve LWLock scalability.
Date: 2014-12-25 16:49:00
Message-ID: E1Y4Bau-0005fT-DD@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve LWLock scalability.

The old LWLock implementation had the problem that concurrent lock
acquisitions required exclusively acquiring a spinlock. Often that
could lead to acquirers waiting behind the spinlock, even if the
actual LWLock was free.

The new implementation doesn't acquire the spinlock when acquiring the
lock itself. Instead the new atomic operations are used to atomically
manipulate the state. Only the waitqueue, used solely in the slow
path, is still protected by the spinlock. Check lwlock.c's header for
an explanation about the used algorithm.

For some common workloads on larger machines this can yield
significant performance improvements. Particularly in read mostly
workloads.

Reviewed-By: Amit Kapila and Robert Haas
Author: Andres Freund

Discussion: 20130926225545(dot)GB26663(at)awork2(dot)anarazel(dot)de

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/ab5194e6f617a9a9e7aadb3dd1cee948a42d0755

Modified Files
--------------
src/backend/storage/lmgr/lwlock.c | 931 +++++++++++++++++++++++++------------
src/include/storage/lwlock.h | 24 +-
2 files changed, 653 insertions(+), 302 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2014-12-25 17:34:53 pgsql: Lockless StrategyGetBuffer clock sweep hot path.
Previous Message Andres Freund 2014-12-25 16:05:11 Re: pgsql: Move pg_lzcompress.c to src/common.