Rewrite the sinval messaging mechanism to reduce contention and avoid
commit3f64154c7467f788a50afe92894e9bac8ff8fd53
authortgl <tgl>
Thu, 19 Jun 2008 21:32:56 +0000 (19 21:32 +0000)
committertgl <tgl>
Thu, 19 Jun 2008 21:32:56 +0000 (19 21:32 +0000)
treef4531e252dd2e5a7b0bdbb583e42a8632dea82ea
parent126e9e19355fe45d61c0556fc4c23b234cb71e22
Rewrite the sinval messaging mechanism to reduce contention and avoid
unnecessary cache resets.  The major changes are:

* When the queue overflows, we only issue a cache reset to the specific
backend or backends that still haven't read the oldest message, rather
than resetting everyone as in the original coding.

* When we observe backend(s) falling well behind, we signal SIGUSR1
to only one backend, the one that is furthest behind and doesn't already
have a signal outstanding for it.  When it finishes catching up, it will
in turn signal SIGUSR1 to the next-furthest-back guy, if there is one that
is far enough behind to justify a signal.  The PMSIGNAL_WAKEN_CHILDREN
mechanism is removed.

* We don't attempt to clean out dead messages after every message-receipt
operation; rather, we do it on the insertion side, and only when the queue
fullness passes certain thresholds.

* Split SInvalLock into SInvalReadLock and SInvalWriteLock so that readers
don't block writers nor vice versa (except during the infrequent queue
cleanout operations).

* Transfer multiple sinval messages for each acquisition of a read or
write lock.
src/backend/postmaster/postmaster.c
src/backend/storage/ipc/sinval.c
src/backend/storage/ipc/sinvaladt.c
src/backend/utils/cache/inval.c
src/include/storage/lwlock.h
src/include/storage/pmsignal.h
src/include/storage/sinval.h
src/include/storage/sinvaladt.h