From ab8121a407280bf39bdd401699476feb39ccd0f7 Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Wed, 23 Jul 2025 18:41:56 +0000 Subject: runtime/metrics: add metric for total goroutines created For #15490. Change-Id: Ic587dda1f42d613ea131a6b53ce6ba6e6cadf4c7 Reviewed-on: https://go-review.googlesource.com/c/go/+/690398 Reviewed-by: Michael Pratt Auto-Submit: Michael Knyszek LUCI-TryBot-Result: Go LUCI --- src/runtime/runtime2.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/runtime/runtime2.go') diff --git a/src/runtime/runtime2.go b/src/runtime/runtime2.go index c5d15754ec..a80a34a18e 100644 --- a/src/runtime/runtime2.go +++ b/src/runtime/runtime2.go @@ -764,6 +764,9 @@ type p struct { // gcStopTime is the nanotime timestamp that this P last entered _Pgcstop. gcStopTime int64 + // goroutinesCreated is the total count of goroutines created by this P. + goroutinesCreated uint64 + // xRegs is the per-P extended register state used by asynchronous // preemption. This is an empty struct on platforms that don't use extended // register state. @@ -892,6 +895,10 @@ type schedt struct { // M, but waiting for locks within the runtime. This field stores the value // for Ms that have exited. totalRuntimeLockWaitTime atomic.Int64 + + // goroutinesCreated (plus the value of goroutinesCreated on each P in allp) + // is the sum of all goroutines created by the program. + goroutinesCreated atomic.Uint64 } // Values for the flags field of a sigTabT. -- cgit v1.3