postgresql/src/backend/postmaster
Robert Haas 3761fe3c20 Simplify LWLock tranche machinery by removing array_base/array_stride.
array_base and array_stride were added so that we could identify the
offset of an LWLock within a tranche, but this facility is only very
marginally used apart from the main tranche.  So, give every lock in
the main tranche its own tranche ID and get rid of array_base,
array_stride, and all that's attached.  For debugging facilities
(Trace_lwlocks and LWLOCK_STATS) print the pointer address of the
LWLock using %p instead of the offset.  This is arguably more useful,
and certainly a lot cheaper.  Drop the offset-within-tranche from
the information reported to dtrace and from one can't-happen message
inside lwlock.c.

The main user-visible impact of this change is that pg_stat_activity
will now report all waits for LWLocks as "LWLock" rather than
reporting some as "LWLockTranche" and others as "LWLockNamed".

The main motivation for this change is that the need to specify an
array_base and an array_stride is awkward for parallel query.  There
is only a very limited supply of tranche IDs so we can't just keep
allocating new ones, and if we try to use the same tranche IDs every
time then we run into trouble when multiple parallel contexts are
use simultaneously.  So if we didn't get rid of this mechanism we'd
have to make it even more complicated.  By simplifying it in this
way, we instead reduce the size of the generated code for lwlock.c
by about 5%.

Discussion: http://postgr.es/m/CA+TgmoYsFn6NUW1x0AZtupJGUAs1UDY4dJtCN47_Q6D0sP80PA@mail.gmail.com
2016-12-16 11:29:23 -05:00
..
Makefile Allow background workers to be started dynamically. 2013-07-16 13:02:15 -04:00
autovacuum.c Delete deleteWhatDependsOn() in favor of more performDeletion() flag bits. 2016-12-02 14:57:55 -05:00
bgworker.c Add max_parallel_workers GUC. 2016-12-02 07:42:58 -05:00
bgwriter.c Support condition variables. 2016-11-22 14:27:11 -05:00
checkpointer.c Support condition variables. 2016-11-22 14:27:11 -05:00
fork_process.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
pgarch.c Extend framework from commit 53be0b1ad to report latch waits. 2016-10-04 11:01:42 -04:00
pgstat.c Simplify LWLock tranche machinery by removing array_base/array_stride. 2016-12-16 11:29:23 -05:00
postmaster.c Make the different Unix-y semaphore implementations ABI-compatible. 2016-12-12 13:32:10 -05:00
startup.c Rework wait for AccessExclusiveLocks on Hot Standby 2016-03-10 19:26:24 +00:00
syslogger.c Fix another Windows compile break. 2016-10-04 13:14:19 -04:00
walwriter.c Support condition variables. 2016-11-22 14:27:11 -05:00