diff options
Diffstat (limited to 'src/backend/storage/lmgr/lwlock.c')
-rw-r--r-- | src/backend/storage/lmgr/lwlock.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index 95d4b37bef3..5e1ce1775cb 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -95,6 +95,7 @@ static int counts_for_pid = 0; static int *sh_acquire_counts; static int *ex_acquire_counts; static int *block_counts; +static int *spin_delay_counts; #endif #ifdef LOCK_DEBUG @@ -134,6 +135,7 @@ init_lwlock_stats(void) sh_acquire_counts = calloc(numLocks, sizeof(int)); ex_acquire_counts = calloc(numLocks, sizeof(int)); + spin_delay_counts = calloc(numLocks, sizeof(int)); block_counts = calloc(numLocks, sizeof(int)); counts_for_pid = MyProcPid; on_shmem_exit(print_lwlock_stats, 0); @@ -151,10 +153,10 @@ print_lwlock_stats(int code, Datum arg) for (i = 0; i < numLocks; i++) { - if (sh_acquire_counts[i] || ex_acquire_counts[i] || block_counts[i]) - fprintf(stderr, "PID %d lwlock %d: shacq %u exacq %u blk %u\n", + if (sh_acquire_counts[i] || ex_acquire_counts[i] || block_counts[i] || spin_delay_counts[i]) + fprintf(stderr, "PID %d lwlock %d: shacq %u exacq %u blk %u spindelay %u\n", MyProcPid, i, sh_acquire_counts[i], ex_acquire_counts[i], - block_counts[i]); + block_counts[i], spin_delay_counts[i]); } LWLockRelease(0); @@ -395,7 +397,11 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) bool mustwait; /* Acquire mutex. Time spent holding mutex should be short! */ +#ifdef LWLOCK_STATS + spin_delay_counts[lockid] += SpinLockAcquire(&lock->mutex); +#else SpinLockAcquire(&lock->mutex); +#endif /* If retrying, allow LWLockRelease to release waiters again */ if (retry) |