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

@ -48,7 +48,6 @@
package runtime
import (
"runtime/internal/atomic"
"unsafe"
)
@ -273,15 +272,10 @@ type pageAlloc struct {
// scavenge.
index scavengeIndex
// released is the amount of memory released this generation.
// released is the amount of memory released this scavenge cycle.
//
// Updated atomically.
released uintptr
// scavengeAssistTime is the time spent scavenging in the last GC cycle.
//
// This is reset once a GC cycle ends.
assistTime atomic.Int64
}
// mheap_.lock. This level of indirection makes it possible