]> Cypherpunks repositories - gostls13.git/commit
runtime: split mutex profile clocks
authorRhys Hiltner <rhys.hiltner@gmail.com>
Wed, 22 May 2024 06:17:13 +0000 (23:17 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 22 May 2024 14:34:20 +0000 (14:34 +0000)
commit8ab131fb1256a4a795c610e145c022e22e2d1567
tree48ee552c8fd03cc1489e41e76fec7178a454c187
parent1d3d7d395e6081c0cdc437c56c4c0318b70fb685
runtime: split mutex profile clocks

Mutex contention measurements work with two clocks: nanotime for use in
runtime/metrics, and cputicks for the runtime/pprof profile. They're
subject to different sampling rates: the runtime/metrics view is always
enabled, but the profile is adjustable and is turned off by default.
They have different levels of overhead: it can take as little as one
instruction to read cputicks while nanotime calls are more elaborate
(although some platforms implement cputicks as a nanotime call). The use
of the timestamps is also different: the profile's view needs to attach
the delay in some Ms' lock2 calls to another M's unlock2 call stack, but
the metric's view is only an int64.

Treat them differently. Don't bother threading the nanotime clock
through to the unlock2 call, measure and report it directly within
lock2. Sample nanotime at a constant gTrackingPeriod.

Don't consult any clocks unless the mutex is actually contended.

Continue liberal use of cputicks for now.

For #66999

Change-Id: I1c2085ea0e695bfa90c30fadedc99ced9eb1f69e
Reviewed-on: https://go-review.googlesource.com/c/go/+/586796
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Rhys Hiltner <rhys.hiltner@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
src/runtime/lock_futex.go
src/runtime/lock_sema.go
src/runtime/mprof.go