You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
runtime,runtime/metrics: track running time per goroutine
Fixesgolang#41554.
This commit introduces a /sched/goroutine/running:nanoseconds metric,
defined as the total time spent by a goroutine in the running state.
This measurement is useful for systems that would benefit from
fine-grained CPU attribution.
An alternative to scheduler-backed CPU attribution would be the use of
profiler labels. Given it's common to spawn multiple goroutines for the
same task, goroutine-backed statistics can easily become misleading.
Profiler labels instead let you measure CPU performance across a set of
cooperating goroutines. That said, it has two downsides:
- performance overhead; for high-performance systems that care about
fine-grained CPU attribution (databases for e.g. that want to measure
total CPU time spent processing each request), profiler labels are too
cost-prohibitive, especially given the Go runtime has a much cheaper
and more granular view of the data needed
- inaccuracy and imprecision, as evaluated in
golang#36821
It's worth noting that we already export /sched/latencies:seconds to
track scheduling latencies, i.e. time spent by a goroutine in the
runnable state (go-review.googlesource.com/c/go/+/308933). This commit
does effectively the same except for the running state on the requesting
goroutine. Users are free to use this metric to power histograms or
tracking on-CPU time across a set of goroutines.
Change-Id: Ie78336a3ddeca0521ae29cce57bc7a5ea67da297
0 commit comments