mirror of
https://github.com/postgres/postgres.git
synced 2025-11-16 15:02:33 +03:00
Divide the lock manager's shared state into 'partitions', so as to
reduce contention for the former single LockMgrLock. Per my recent proposal. I set it up for 16 partitions, but on a pgbench test this gives only a marginal further improvement over 4 partitions --- we need to test more scenarios to choose the number of partitions.
This commit is contained in:
@@ -8,14 +8,14 @@
|
||||
* exclusive and shared lock modes (to support read/write and read-only
|
||||
* access to a shared object). There are few other frammishes. User-level
|
||||
* locking should be done with the full lock manager --- which depends on
|
||||
* an LWLock to protect its shared state.
|
||||
* LWLocks to protect its shared state.
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.35 2005/12/06 23:08:33 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/lwlock.c,v 1.36 2005/12/11 21:02:18 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -125,7 +125,10 @@ NumLWLocks(void)
|
||||
*/
|
||||
|
||||
/* Predefined LWLocks */
|
||||
numLocks = (int) NumFixedLWLocks;
|
||||
numLocks = (int) FirstLockMgrLock;
|
||||
|
||||
/* lock.c gets the ones starting at FirstLockMgrLock */
|
||||
numLocks += NUM_LOCK_PARTITIONS;
|
||||
|
||||
/* bufmgr.c needs two for each shared buffer */
|
||||
numLocks += 2 * NBuffers;
|
||||
@@ -204,10 +207,11 @@ CreateLWLocks(void)
|
||||
|
||||
/*
|
||||
* Initialize the dynamic-allocation counter, which is stored just before
|
||||
* the first LWLock.
|
||||
* the first LWLock. The LWLocks used by lock.c are not dynamically
|
||||
* allocated, it just assumes it has them.
|
||||
*/
|
||||
LWLockCounter = (int *) ((char *) LWLockArray - 2 * sizeof(int));
|
||||
LWLockCounter[0] = (int) NumFixedLWLocks;
|
||||
LWLockCounter[0] = (int) FirstLockMgrLock + NUM_LOCK_PARTITIONS;
|
||||
LWLockCounter[1] = numLocks;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user