diff options
Diffstat (limited to 'src/backend/storage/lmgr/lwlock.c')
-rw-r--r-- | src/backend/storage/lmgr/lwlock.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index 84691df053b..d43fb61edb3 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -344,18 +344,15 @@ NumLWLocks(void) int numLocks; /* - * Possibly this logic should be spread out among the affected modules, - * the same way that shmem space estimation is done. But for now, there - * are few enough users of LWLocks that we can get away with just keeping - * the knowledge here. + * Many users of LWLocks no longer reserve space in the main array here, + * but instead allocate separate tranches. The latter approach has the + * advantage of allowing LWLOCK_STATS and LOCK_DEBUG output to produce + * more useful output. */ /* Predefined LWLocks */ numLocks = NUM_FIXED_LWLOCKS; - /* bufmgr.c needs two for each shared buffer */ - numLocks += 2 * NBuffers; - /* proc.c needs one for each backend or auxiliary process */ numLocks += MaxBackends + NUM_AUXILIARY_PROCS; @@ -423,6 +420,10 @@ CreateLWLocks(void) StaticAssertExpr(LW_VAL_EXCLUSIVE > (uint32) MAX_BACKENDS, "MAX_BACKENDS too big for lwlock.c"); + StaticAssertExpr(sizeof(LWLock) <= LWLOCK_MINIMAL_SIZE && + sizeof(LWLock) <= LWLOCK_PADDED_SIZE, + "Miscalculated LWLock padding"); + if (!IsUnderPostmaster) { int numLocks = NumLWLocks(); |