[PATCH] Identify LWLocks in tracepoints
Craig Ringer <craig.ringer@enterprisedb.com>
From: Craig Ringer <craig.ringer@enterprisedb.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2020-12-19T05:00:01Z
Lists: pgsql-hackers
Attachments
- v1-0004-Comments-on-LWLock-tranches.patch (application/x-patch) patch v1-0004
- v1-0001-Remove-bogus-lwlock__acquire-tracepoint-from-LWLo.patch (application/x-patch) patch v1-0001
- v1-0002-Pass-the-target-LWLock-and-tranche-ID-to-LWLock-t.patch (application/x-patch) patch v1-0002
- v1-0003-Add-to-the-tracepoints-in-LWLock-routines.patch (application/x-patch) patch v1-0003
Hi all The attached patch set follows on from the discussion in [1] "Add LWLock blocker(s) information" by adding the actual LWLock* and the numeric tranche ID to each LWLock related TRACE_POSTGRESQL_foo tracepoint. This does not provide complete information on blockers, because it's not necessarily valid to compare any two LWLock* pointers between two process address spaces. The locks could be in DSM segments, and those DSM segments could be mapped at different addresses. I wasn't able to work out a sensible way to map a LWLock* to any sort of (tranche-id, lock-index) because there's no requirement that locks in a tranche be contiguous or known individually to the lmgr. Despite that, the patches improve the information available for LWLock analysis significantly. Patch 1 fixes a bogus tracepoint where an lwlock__acquire event would be fired from LWLockWaitForVar, despite that function never actually acquiring the lock. Patch 2 adds the tranche id and lock pointer for each trace hit. This makes it possible to differentiate between individual locks within a tranche, and (so long as they aren't tranches in a DSM segment) compare locks between processes. That means you can do lock-order analysis etc, which was not previously especially feasible. Traces also don't have to do userspace reads for the tranche name all the time, so the trace can run with lower overhead. Patch 3 adds a single-path tracepoint for all lock acquires and releases, so you only have to probe the lwlock__acquired and lwlock__release events to see all acquires/releases, whether conditional or otherwise. It also adds start markers that can be used for timing wallclock duration of LWLock acquires/releases. Patch 4 adds some comments on LWLock tranches to try to address some points I found confusing and hard to understand when investigating this topic. [1] https://www.postgresql.org/message-id/CAGRY4nz%3DSEs3qc1R6xD3max7sg3kS-L81eJk2aLUWSQAeAFJTA%40mail.gmail.com .
Commits
-
Emit dummy statements for probes.d probes when disabled
- 0d204a4b09f7 13.3 landed
- fa8fbadb934b 14.0 landed
-
Prevent lwlock dtrace probes from unnecessary work
- e48ce7ef0ef8 13.3 landed
- b94409a02f61 14.0 landed
-
doc: Fix typo in logicaldecoding.sgml.
- 5fe83adad9ef 14.0 cited
-
Move lwlock-release probe back where it belongs
- 96ae658e6238 14.0 landed
-
Remove bogus tracepoint
- 09418bed67a7 14.0 landed
-
Simplify LWLock tranche machinery by removing array_base/array_stride.
- 3761fe3c20bb 10.0 cited
-
Improve LWLock scalability.
- ab5194e6f617 9.5.0 cited