Skip to content

Commit 32afcc9

Browse files
committed
runtime/metrics: change unit on *-by-size metrics to match bucket unit
This change modifies the *-by-size metrics' units to be based off the bucket's unit (bytes) as opposed to the unit of the counts (objects). This convention is more in-line with distributions in other metrics systems. Change-Id: Id3b68a09f52f0e1ff9f4346f613ae1cbd9f52f73 Reviewed-on: https://go-review.googlesource.com/c/go/+/282352 Run-TryBot: Michael Knyszek <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Austin Clements <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Trust: Michael Knyszek <[email protected]>
1 parent c6513bc commit 32afcc9

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

src/runtime/metrics.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func initMetrics() {
8686
out.scalar = in.sysStats.gcCyclesDone
8787
},
8888
},
89-
"/gc/heap/allocs-by-size:objects": {
89+
"/gc/heap/allocs-by-size:bytes": {
9090
deps: makeStatDepSet(heapStatsDep),
9191
compute: func(in *statAggregate, out *metricValue) {
9292
hist := out.float64HistOrInit(sizeClassBuckets)
@@ -98,7 +98,7 @@ func initMetrics() {
9898
}
9999
},
100100
},
101-
"/gc/heap/frees-by-size:objects": {
101+
"/gc/heap/frees-by-size:bytes": {
102102
deps: makeStatDepSet(heapStatsDep),
103103
compute: func(in *statAggregate, out *metricValue) {
104104
hist := out.float64HistOrInit(sizeClassBuckets)

src/runtime/metrics/description.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ type Description struct {
2323
// Examples of units might be "seconds", "bytes", "bytes/second", "cpu-seconds",
2424
// "byte*cpu-seconds", and "bytes/second/second".
2525
//
26+
// For histograms, multiple units may apply. For instance, the units of the buckets and
27+
// the count. By convention, for histograms, the units of the count are always "samples"
28+
// with the type of sample evident by the metric's name, while the unit in the name
29+
// specifies the buckets' unit.
30+
//
2631
// A complete name might look like "/memory/heap/free:bytes".
2732
Name string
2833

@@ -69,12 +74,12 @@ var allDesc = []Description{
6974
Cumulative: true,
7075
},
7176
{
72-
Name: "/gc/heap/allocs-by-size:objects",
77+
Name: "/gc/heap/allocs-by-size:bytes",
7378
Description: "Distribution of all objects allocated by approximate size.",
7479
Kind: KindFloat64Histogram,
7580
},
7681
{
77-
Name: "/gc/heap/frees-by-size:objects",
82+
Name: "/gc/heap/frees-by-size:bytes",
7883
Description: "Distribution of all objects freed by approximate size.",
7984
Kind: KindFloat64Histogram,
8085
},

src/runtime/metrics/doc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ Below is the full list of supported metrics, ordered lexicographically.
6161
/gc/cycles/total:gc-cycles
6262
Count of all completed GC cycles.
6363
64-
/gc/heap/allocs-by-size:objects
64+
/gc/heap/allocs-by-size:bytes
6565
Distribution of all objects allocated by approximate size.
6666
67-
/gc/heap/frees-by-size:objects
67+
/gc/heap/frees-by-size:bytes
6868
Distribution of all objects freed by approximate size.
6969
7070
/gc/heap/goal:bytes

src/runtime/metrics_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestReadMetrics(t *testing.T) {
7070
checkUint64(t, name, samples[i].Value.Uint64(), mstats.BuckHashSys)
7171
case "/memory/classes/total:bytes":
7272
checkUint64(t, name, samples[i].Value.Uint64(), mstats.Sys)
73-
case "/gc/heap/allocs-by-size:objects":
73+
case "/gc/heap/allocs-by-size:bytes":
7474
hist := samples[i].Value.Float64Histogram()
7575
// Skip size class 0 in BySize, because it's always empty and not represented
7676
// in the histogram.
@@ -84,7 +84,7 @@ func TestReadMetrics(t *testing.T) {
8484
t.Errorf("histogram counts do not much BySize for class %d: got %d, want %d", i, c, m)
8585
}
8686
}
87-
case "/gc/heap/frees-by-size:objects":
87+
case "/gc/heap/frees-by-size:bytes":
8888
hist := samples[i].Value.Float64Histogram()
8989
// Skip size class 0 in BySize, because it's always empty and not represented
9090
// in the histogram.
@@ -161,9 +161,9 @@ func TestReadMetricsConsistency(t *testing.T) {
161161
totalVirtual.got = samples[i].Value.Uint64()
162162
case "/gc/heap/objects:objects":
163163
objects.total = samples[i].Value.Uint64()
164-
case "/gc/heap/allocs-by-size:objects":
164+
case "/gc/heap/allocs-by-size:bytes":
165165
objects.alloc = samples[i].Value.Float64Histogram()
166-
case "/gc/heap/frees-by-size:objects":
166+
case "/gc/heap/frees-by-size:bytes":
167167
objects.free = samples[i].Value.Float64Histogram()
168168
case "/gc/cycles:gc-cycles":
169169
gc.numGC = samples[i].Value.Uint64()

0 commit comments

Comments
 (0)