runtime,runtime/metrics: clarify OS stack metrics

There are some subtle details here about measuring OS stacks in cgo
programs. There's also an expectation about magnitude in the MemStats
docs that isn't in the runtime/metrics docs. Fix both.

Fixes #54396.

Change-Id: I6b60a62a4a304e6688e7ab4d511d66193fc25321
Reviewed-on: https://go-review.googlesource.com/c/go/+/502156
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
Michael Anthony Knyszek 2023-06-09 19:14:55 +00:00 committed by Gopher Robot
parent e126572f8a
commit b2215e49c7
3 changed files with 33 additions and 8 deletions

View file

@ -339,9 +339,11 @@ var allDesc = []Description{
Kind: KindUint64,
},
{
Name: "/memory/classes/heap/stacks:bytes",
Description: "Memory allocated from the heap that is reserved for stack space, whether or not it is currently in-use.",
Kind: KindUint64,
Name: "/memory/classes/heap/stacks:bytes",
Description: "Memory allocated from the heap that is reserved for stack space, whether or not it is currently in-use. " +
"Currently, this represents all stack memory for goroutines. It also includes all OS thread stacks in non-cgo programs. " +
"Note that stacks may be allocated differently in the future, and this may change.",
Kind: KindUint64,
},
{
Name: "/memory/classes/heap/unused:bytes",
@ -374,9 +376,13 @@ var allDesc = []Description{
Kind: KindUint64,
},
{
Name: "/memory/classes/os-stacks:bytes",
Description: "Stack memory allocated by the underlying operating system.",
Kind: KindUint64,
Name: "/memory/classes/os-stacks:bytes",
Description: "Stack memory allocated by the underlying operating system. " +
"In non-cgo programs this metric is currently zero. This may change in the future." +
"In cgo programs this metric includes OS thread stacks allocated directly from the OS. " +
"Currently, this only accounts for one stack in c-shared and c-archive build modes, " +
"and other sources of stacks from the OS are not measured. This too may change in the future.",
Kind: KindUint64,
},
{
Name: "/memory/classes/other:bytes",