pgsql: Add a small cache of locks owned by a resource owner in Resource

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Add a small cache of locks owned by a resource owner in Resource
Date: 2012-06-21 12:30:37
Message-ID: E1ShgWz-00013h-Ve@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Add a small cache of locks owned by a resource owner in ResourceOwner.

This speeds up reassigning locks to the parent owner, when the transaction
holds a lot of locks, but only a few of them belong to the current resource
owner. This is particularly helps pg_dump when dumping a large number of
objects.

The cache can hold up to 15 locks in each resource owner. After that, the
cache is marked as overflowed, and we fall back to the old method of
scanning the whole local lock table. The tradeoff here is that the cache has
to be scanned whenever a lock is released, so if the cache is too large,
lock release becomes more expensive. 15 seems enough to cover pg_dump, and
doesn't have much impact on lock release.

Jeff Janes, reviewed by Amit Kapila and Heikki Linnakangas.

Branch
------
master

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

Modified Files
--------------
src/backend/storage/lmgr/lock.c | 154 ++++++++++++++++++++++-----------
src/backend/utils/resowner/resowner.c | 95 ++++++++++++++++++++-
src/include/storage/lock.h | 4 +-
src/include/utils/resowner.h | 5 +
4 files changed, 205 insertions(+), 53 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2012-06-21 19:38:03 pgsql: Repair comment mangled by a pgindent run long ago
Previous Message Tom Lane 2012-06-21 00:15:50 pgsql: Remove incomplete/incorrect support for zero-column foreign keys