]> Cypherpunks.ru repositories - gostls13.git/blob - src/runtime/metrics/doc.go
runtime: measure stack usage; start stacks larger if needed
[gostls13.git] / src / runtime / metrics / doc.go
1 // Copyright 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 /*
6 Package metrics provides a stable interface to access implementation-defined
7 metrics exported by the Go runtime. This package is similar to existing functions
8 like runtime.ReadMemStats and debug.ReadGCStats, but significantly more general.
9
10 The set of metrics defined by this package may evolve as the runtime itself
11 evolves, and also enables variation across Go implementations, whose relevant
12 metric sets may not intersect.
13
14 # Interface
15
16 Metrics are designated by a string key, rather than, for example, a field name in
17 a struct. The full list of supported metrics is always available in the slice of
18 Descriptions returned by All. Each Description also includes useful information
19 about the metric.
20
21 Thus, users of this API are encouraged to sample supported metrics defined by the
22 slice returned by All to remain compatible across Go versions. Of course, situations
23 arise where reading specific metrics is critical. For these cases, users are
24 encouraged to use build tags, and although metrics may be deprecated and removed,
25 users should consider this to be an exceptional and rare event, coinciding with a
26 very large change in a particular Go implementation.
27
28 Each metric key also has a "kind" that describes the format of the metric's value.
29 In the interest of not breaking users of this package, the "kind" for a given metric
30 is guaranteed not to change. If it must change, then a new metric will be introduced
31 with a new key and a new "kind."
32
33 # Metric key format
34
35 As mentioned earlier, metric keys are strings. Their format is simple and well-defined,
36 designed to be both human and machine readable. It is split into two components,
37 separated by a colon: a rooted path and a unit. The choice to include the unit in
38 the key is motivated by compatibility: if a metric's unit changes, its semantics likely
39 did also, and a new key should be introduced.
40
41 For more details on the precise definition of the metric key's path and unit formats, see
42 the documentation of the Name field of the Description struct.
43
44 # A note about floats
45
46 This package supports metrics whose values have a floating-point representation. In
47 order to improve ease-of-use, this package promises to never produce the following
48 classes of floating-point values: NaN, infinity.
49
50 # Supported metrics
51
52 Below is the full list of supported metrics, ordered lexicographically.
53
54         /gc/cycles/automatic:gc-cycles
55                 Count of completed GC cycles generated by the Go runtime.
56
57         /gc/cycles/forced:gc-cycles
58                 Count of completed GC cycles forced by the application.
59
60         /gc/cycles/total:gc-cycles
61                 Count of all completed GC cycles.
62
63         /gc/heap/allocs-by-size:bytes
64                 Distribution of heap allocations by approximate size.
65                 Note that this does not include tiny objects as defined by /gc/heap/tiny/allocs:objects,
66                 only tiny blocks.
67
68         /gc/heap/allocs:bytes
69                 Cumulative sum of memory allocated to the heap by the application.
70
71         /gc/heap/allocs:objects
72                 Cumulative count of heap allocations triggered by the application.
73                 Note that this does not include tiny objects as defined by /gc/heap/tiny/allocs:objects,
74                 only tiny blocks.
75
76         /gc/heap/frees-by-size:bytes
77                 Distribution of freed heap allocations by approximate size.
78                 Note that this does not include tiny objects as defined by /gc/heap/tiny/allocs:objects,
79                 only tiny blocks.
80
81         /gc/heap/frees:bytes
82                 Cumulative sum of heap memory freed by the garbage collector.
83
84         /gc/heap/frees:objects
85                 Cumulative count of heap allocations whose storage was freed by the garbage collector.
86                 Note that this does not include tiny objects as defined by /gc/heap/tiny/allocs:objects,
87                 only tiny blocks.
88
89         /gc/heap/goal:bytes
90                 Heap size target for the end of the GC cycle.
91
92         /gc/heap/objects:objects
93                 Number of objects, live or unswept, occupying heap memory.
94
95         /gc/heap/tiny/allocs:objects
96                 Count of small allocations that are packed together into blocks.
97                 These allocations are counted separately from other allocations
98                 because each individual allocation is not tracked by the runtime,
99                 only their block. Each block is already accounted for in
100                 allocs-by-size and frees-by-size.
101
102         /gc/pauses:seconds
103                 Distribution individual GC-related stop-the-world pause latencies.
104
105         /gc/stack/starting-size:bytes
106                 The stack size of new goroutines.
107
108         /memory/classes/heap/free:bytes
109                 Memory that is completely free and eligible to be returned to
110                 the underlying system, but has not been. This metric is the
111                 runtime's estimate of free address space that is backed by
112                 physical memory.
113
114         /memory/classes/heap/objects:bytes
115                 Memory occupied by live objects and dead objects that have
116                 not yet been marked free by the garbage collector.
117
118         /memory/classes/heap/released:bytes
119                 Memory that is completely free and has been returned to
120                 the underlying system. This metric is the runtime's estimate of
121                 free address space that is still mapped into the process, but
122                 is not backed by physical memory.
123
124         /memory/classes/heap/stacks:bytes
125                 Memory allocated from the heap that is reserved for stack
126                 space, whether or not it is currently in-use.
127
128         /memory/classes/heap/unused:bytes
129                 Memory that is reserved for heap objects but is not currently
130                 used to hold heap objects.
131
132         /memory/classes/metadata/mcache/free:bytes
133                 Memory that is reserved for runtime mcache structures, but
134                 not in-use.
135
136         /memory/classes/metadata/mcache/inuse:bytes
137                 Memory that is occupied by runtime mcache structures that
138                 are currently being used.
139
140         /memory/classes/metadata/mspan/free:bytes
141                 Memory that is reserved for runtime mspan structures, but
142                 not in-use.
143
144         /memory/classes/metadata/mspan/inuse:bytes
145                 Memory that is occupied by runtime mspan structures that are
146                 currently being used.
147
148         /memory/classes/metadata/other:bytes
149                 Memory that is reserved for or used to hold runtime
150                 metadata.
151
152         /memory/classes/os-stacks:bytes
153                 Stack memory allocated by the underlying operating system.
154
155         /memory/classes/other:bytes
156                 Memory used by execution trace buffers, structures for
157                 debugging the runtime, finalizer and profiler specials, and
158                 more.
159
160         /memory/classes/profiling/buckets:bytes
161                 Memory that is used by the stack trace hash map used for
162                 profiling.
163
164         /memory/classes/total:bytes
165                 All memory mapped by the Go runtime into the current process
166                 as read-write. Note that this does not include memory mapped
167                 by code called via cgo or via the syscall package.
168                 Sum of all metrics in /memory/classes.
169
170         /sched/goroutines:goroutines
171                 Count of live goroutines.
172
173         /sched/latencies:seconds
174                 Distribution of the time goroutines have spent in the scheduler
175                 in a runnable state before actually running.
176 */
177 package metrics