pgsql: Rewrite the sinval messaging mechanism to reduce contention and

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Rewrite the sinval messaging mechanism to reduce contention and
Date: 2008-06-19 21:32:56
Message-ID: 20080619213256.B0489754595@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
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.

Modified Files:
--------------
pgsql/src/backend/postmaster:
postmaster.c (r1.558 -> r1.559)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/postmaster/postmaster.c?r1=1.558&r2=1.559)
pgsql/src/backend/storage/ipc:
sinval.c (r1.85 -> r1.86)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/storage/ipc/sinval.c?r1=1.85&r2=1.86)
sinvaladt.c (r1.70 -> r1.71)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/storage/ipc/sinvaladt.c?r1=1.70&r2=1.71)
pgsql/src/backend/utils/cache:
inval.c (r1.85 -> r1.86)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/cache/inval.c?r1=1.85&r2=1.86)
pgsql/src/include/storage:
lwlock.h (r1.38 -> r1.39)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/storage/lwlock.h?r1=1.38&r2=1.39)
pmsignal.h (r1.19 -> r1.20)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/storage/pmsignal.h?r1=1.19&r2=1.20)
sinval.h (r1.47 -> r1.48)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/storage/sinval.h?r1=1.47&r2=1.48)
sinvaladt.h (r1.47 -> r1.48)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/storage/sinvaladt.h?r1=1.47&r2=1.48)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2008-06-20 00:24:54 pgsql: Seems I was too optimistic in supposing that sinval's maxMsgNum
Previous Message Tom Lane 2008-06-19 16:52:31 pgsql: Fix a few places that were non-multibyte-safe in tsearch