1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-18 02:02:55 +03:00

Implement new 'lightweight lock manager' that's intermediate between

existing lock manager and spinlocks: it understands exclusive vs shared
lock but has few other fancy features.  Replace most uses of spinlocks
with lightweight locks.  All remaining uses of spinlocks have very short
lock hold times (a few dozen instructions), so tweak spinlock backoff
code to work efficiently given this assumption.  All per my proposal on
pghackers 26-Sep-01.
This commit is contained in:
Tom Lane
2001-09-29 04:02:27 +00:00
parent 818fb55ac4
commit 499abb0c0f
46 changed files with 1595 additions and 1355 deletions

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.40 2001/06/19 19:42:15 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.41 2001/09/29 04:02:24 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -83,7 +83,7 @@ SIBufferInit(int maxBackends)
* <0 Some other failure (not currently used)
*
* NB: this routine, and all following ones, must be executed with the
* SInvalLock spinlock held, since there may be multiple backends trying
* SInvalLock lock held, since there may be multiple backends trying
* to access the buffer.
*/
int
@@ -152,7 +152,7 @@ CleanupInvalidationState(int status, Datum arg)
Assert(PointerIsValid(segP));
SpinAcquire(SInvalLock);
LWLockAcquire(SInvalLock, LW_EXCLUSIVE);
/* Mark myself inactive */
segP->procState[MyBackendId - 1].nextMsgNum = -1;
@@ -167,7 +167,7 @@ CleanupInvalidationState(int status, Datum arg)
}
segP->lastBackend = i;
SpinRelease(SInvalLock);
LWLockRelease(SInvalLock);
}
/*
@@ -267,6 +267,10 @@ SISetProcStateInvalid(SISeg *segP)
* 1: next SI message has been extracted into *data
* (there may be more messages available after this one!)
* -1: SI reset message extracted
*
* NB: this can run in parallel with other instances of SIGetDataEntry
* executing on behalf of other backends. See comments in sinval.c in
* ReceiveSharedInvalidMessages().
*/
int
SIGetDataEntry(SISeg *segP, int backendId,