runtime/metrics: add CPU stats

This changes adds a breakdown for estimated CPU usage by time. These
estimates are not based on real on-CPU counters, so each metric has a
disclaimer explaining so. They can, however, be more reasonably
compared to a total CPU time metric that this change also adds.

Fixes #47216.

Change-Id: I125006526be9f8e0d609200e193da5a78d9935be
Reviewed-on: https://go-review.googlesource.com/c/go/+/404307
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Josh MacDonald <jmacd@lightstep.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Michael Anthony Knyszek 2022-05-06 20:11:28 +00:00 committed by Gopher Robot
parent 87eda2a782
commit b7c28f484d
11 changed files with 459 additions and 21 deletions

View file

@ -54,6 +54,90 @@ Below is the full list of supported metrics, ordered lexicographically.
/cgo/go-to-c-calls:calls
Count of calls made from Go to C by the current process.
/cpu/classes/gc/mark/assist:cpu-seconds
Estimated total CPU time goroutines spent performing GC tasks
to assist the GC and prevent it from falling behind the application.
This metric is an overestimate, and not directly comparable to
system CPU time measurements. Compare only with other /cpu/classes
metrics.
/cpu/classes/gc/mark/dedicated:cpu-seconds
Estimated total CPU time spent performing GC tasks on
processors (as defined by GOMAXPROCS) dedicated to those tasks.
This includes time spent with the world stopped due to the GC.
This metric is an overestimate, and not directly comparable to
system CPU time measurements. Compare only with other /cpu/classes
metrics.
/cpu/classes/gc/mark/idle:cpu-seconds
Estimated total CPU time spent performing GC tasks on
spare CPU resources that the Go scheduler could not otherwise find
a use for. This should be subtracted from the total GC CPU time to
obtain a measure of compulsory GC CPU time.
This metric is an overestimate, and not directly comparable to
system CPU time measurements. Compare only with other /cpu/classes
metrics.
/cpu/classes/gc/pause:cpu-seconds
Estimated total CPU time spent with the application paused by
the GC. Even if only one thread is running during the pause, this is
computed as GOMAXPROCS times the pause latency because nothing else
can be executing. This is the exact sum of samples in /gc/pause:seconds
if each sample is multiplied by GOMAXPROCS at the time it is taken.
This metric is an overestimate, and not directly comparable to
system CPU time measurements. Compare only with other /cpu/classes
metrics.
/cpu/classes/gc/total:cpu-seconds
Estimated total CPU time spent performing GC tasks.
This metric is an overestimate, and not directly comparable to
system CPU time measurements. Compare only with other /cpu/classes
metrics. Sum of all metrics in /cpu/classes/gc.
/cpu/classes/idle:cpu-seconds
Estimated total available CPU time not spent executing any Go or Go
runtime code. In other words, the part of /cpu/classes/total:cpu-seconds
that was unused.
This metric is an overestimate, and not directly comparable to
system CPU time measurements. Compare only with other /cpu/classes
metrics.
/cpu/classes/scavenge/assist:cpu-seconds
Estimated total CPU time spent returning unused memory to the
underlying platform in response eagerly in response to memory pressure.
This metric is an overestimate, and not directly comparable to
system CPU time measurements. Compare only with other /cpu/classes
metrics.
/cpu/classes/scavenge/background:cpu-seconds
Estimated total CPU time spent performing background tasks
to return unused memory to the underlying platform.
This metric is an overestimate, and not directly comparable to
system CPU time measurements. Compare only with other /cpu/classes
metrics.
/cpu/classes/scavenge/total:cpu-seconds
Estimated total CPU time spent performing tasks that return
unused memory to the underlying platform.
This metric is an overestimate, and not directly comparable to
system CPU time measurements. Compare only with other /cpu/classes
metrics. Sum of all metrics in /cpu/classes/scavenge.
/cpu/classes/total:cpu-seconds
Estimated total available CPU time for user Go code or the Go runtime, as
defined by GOMAXPROCS. In other words, GOMAXPROCS integrated over the
wall-clock duration this process has been executing for.
This metric is an overestimate, and not directly comparable to
system CPU time measurements. Compare only with other /cpu/classes
metrics. Sum of all metrics in /cpu/classes.
/cpu/classes/user:cpu-seconds
Estimated total CPU time spent running user Go code. This may
also include some small amount of time spent in the Go runtime.
This metric is an overestimate, and not directly comparable to
system CPU time measurements. Compare only with other /cpu/classes
metrics.
/gc/cycles/automatic:gc-cycles
Count of completed GC cycles generated by the Go runtime.