mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime,runtime/metrics: add memory metrics
This change adds support for a variety of runtime memory metrics and contains the base implementation of Read for the runtime/metrics package, which lives in the runtime. It also adds testing infrastructure for the metrics package, and a bunch of format and documentation tests. For #37112. Change-Id: I16a2c4781eeeb2de0abcb045c15105f1210e2d8a Reviewed-on: https://go-review.googlesource.com/c/go/+/247041 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Trust: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
parent
79781e8dd3
commit
b08dfbaa43
9 changed files with 781 additions and 6 deletions
|
|
@ -10,7 +10,7 @@ type Description struct {
|
|||
//
|
||||
// The format of the metric may be described by the following regular expression.
|
||||
//
|
||||
// ^(?P<name>/[^:]+):(?P<unit>[^:*\/]+(?:[*\/][^:*\/]+)*)$
|
||||
// ^(?P<name>/[^:]+):(?P<unit>[^:*/]+(?:[*/][^:*/]+)*)$
|
||||
//
|
||||
// The format splits the name into two components, separated by a colon: a path which always
|
||||
// starts with a /, and a machine-parseable unit. The name may contain any valid Unicode
|
||||
|
|
@ -26,6 +26,9 @@ type Description struct {
|
|||
// A complete name might look like "/memory/heap/free:bytes".
|
||||
Name string
|
||||
|
||||
// Description is an English language sentence describing the metric.
|
||||
Description string
|
||||
|
||||
// Kind is the kind of value for this metric.
|
||||
//
|
||||
// The purpose of this field is to allow users to filter out metrics whose values are
|
||||
|
|
@ -44,7 +47,80 @@ type Description struct {
|
|||
StopTheWorld bool
|
||||
}
|
||||
|
||||
var allDesc = []Description{}
|
||||
// The English language descriptions below must be kept in sync with the
|
||||
// descriptions of each metric in doc.go.
|
||||
var allDesc = []Description{
|
||||
{
|
||||
Name: "/memory/classes/heap/free:bytes",
|
||||
Description: "Memory that is available for allocation, and may be returned to the underlying system.",
|
||||
Kind: KindUint64,
|
||||
},
|
||||
{
|
||||
Name: "/memory/classes/heap/objects:bytes",
|
||||
Description: "Memory occupied by live objects and dead objects that have not yet been collected.",
|
||||
Kind: KindUint64,
|
||||
},
|
||||
{
|
||||
Name: "/memory/classes/heap/released:bytes",
|
||||
Description: "Memory that has been returned to the underlying system.",
|
||||
Kind: KindUint64,
|
||||
},
|
||||
{
|
||||
Name: "/memory/classes/heap/stacks:bytes",
|
||||
Description: "Memory allocated from the heap that is occupied by stacks.",
|
||||
Kind: KindUint64,
|
||||
},
|
||||
{
|
||||
Name: "/memory/classes/heap/unused:bytes",
|
||||
Description: "Memory that is unavailable for allocation, but cannot be returned to the underlying system.",
|
||||
Kind: KindUint64,
|
||||
},
|
||||
{
|
||||
Name: "/memory/classes/metadata/mcache/free:bytes",
|
||||
Description: "Memory that is reserved for runtime mcache structures, but not in-use.",
|
||||
Kind: KindUint64,
|
||||
},
|
||||
{
|
||||
Name: "/memory/classes/metadata/mcache/inuse:bytes",
|
||||
Description: "Memory that is occupied by runtime mcache structures that are currently being used.",
|
||||
Kind: KindUint64,
|
||||
},
|
||||
{
|
||||
Name: "/memory/classes/metadata/mspan/free:bytes",
|
||||
Description: "Memory that is reserved for runtime mspan structures, but not in-use.",
|
||||
Kind: KindUint64,
|
||||
},
|
||||
{
|
||||
Name: "/memory/classes/metadata/mspan/inuse:bytes",
|
||||
Description: "Memory that is occupied by runtime mspan structures that are currently being used.",
|
||||
Kind: KindUint64,
|
||||
},
|
||||
{
|
||||
Name: "/memory/classes/metadata/other:bytes",
|
||||
Description: "Memory that is reserved for or used to hold runtime metadata.",
|
||||
Kind: KindUint64,
|
||||
},
|
||||
{
|
||||
Name: "/memory/classes/os-stacks:bytes",
|
||||
Description: "Stack memory allocated by the underlying operating system.",
|
||||
Kind: KindUint64,
|
||||
},
|
||||
{
|
||||
Name: "/memory/classes/other:bytes",
|
||||
Description: "Memory used by execution trace buffers, structures for debugging the runtime, finalizer and profiler specials, and more.",
|
||||
Kind: KindUint64,
|
||||
},
|
||||
{
|
||||
Name: "/memory/classes/profiling/buckets:bytes",
|
||||
Description: "Memory that is used by the stack trace hash map used for profiling.",
|
||||
Kind: KindUint64,
|
||||
},
|
||||
{
|
||||
Name: "/memory/classes/total:bytes",
|
||||
Description: "All memory mapped by the Go runtime into the current process as read-write. Note that this does not include memory mapped by code called via cgo or via the syscall package. Sum of all metrics in /memory/classes.",
|
||||
Kind: KindUint64,
|
||||
},
|
||||
}
|
||||
|
||||
// All returns a slice of containing metric descriptions for all supported metrics.
|
||||
func All() []Description {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue