From 5124371c1c7d6e2f5c8ebf821fdd07ea71d564c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Geisend=C3=B6rfer?= Date: Tue, 23 May 2023 12:35:48 +0200 Subject: [PATCH] runtime/metrics: add /gc/scan/total:bytes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For #56857 Change-Id: I10dbc5db506c95b7578c2b6baf051a351f68bb2a Reviewed-on: https://go-review.googlesource.com/c/go/+/497576 TryBot-Result: Gopher Robot Reviewed-by: David Chase Reviewed-by: Michael Knyszek Run-TryBot: Felix Geisendörfer Auto-Submit: Michael Knyszek --- src/runtime/metrics.go | 6 ++++++ src/runtime/metrics/description.go | 5 +++++ src/runtime/metrics/doc.go | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/src/runtime/metrics.go b/src/runtime/metrics.go index 356d21ae7d4d0..4c51efaad9f1b 100644 --- a/src/runtime/metrics.go +++ b/src/runtime/metrics.go @@ -201,6 +201,12 @@ func initMetrics() { out.scalar = gcController.heapScan.Load() }, }, + "/gc/scan/total:bytes": { + compute: func(in *statAggregate, out *metricValue) { + out.kind = metricKindUint64 + out.scalar = gcController.globalsScan.Load() + gcController.heapScan.Load() + gcController.lastStackScan.Load() + }, + }, "/gc/heap/allocs-by-size:bytes": { deps: makeStatDepSet(heapStatsDep), compute: func(in *statAggregate, out *metricValue) { diff --git a/src/runtime/metrics/description.go b/src/runtime/metrics/description.go index ac6f43707593a..b34ffe405dfb3 100644 --- a/src/runtime/metrics/description.go +++ b/src/runtime/metrics/description.go @@ -309,6 +309,11 @@ var allDesc = []Description{ Description: "The number of bytes of stack that were scanned last GC cycle.", Kind: KindUint64, }, + { + Name: "/gc/scan/total:bytes", + Description: "The total amount space that is scannable. Sum of all metrics in /gc/scan.", + Kind: KindUint64, + }, { Name: "/gc/stack/starting-size:bytes", Description: "The stack size of new goroutines.", diff --git a/src/runtime/metrics/doc.go b/src/runtime/metrics/doc.go index 15fba2b5d443e..44e2676ac5d8c 100644 --- a/src/runtime/metrics/doc.go +++ b/src/runtime/metrics/doc.go @@ -225,6 +225,10 @@ Below is the full list of supported metrics, ordered lexicographically. /gc/scan/stack:bytes The number of bytes of stack that were scanned last GC cycle. + /gc/scan/total:bytes + The total amount space that is scannable. Sum of all metrics in + /gc/scan. + /gc/stack/starting-size:bytes The stack size of new goroutines.