]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/metrics: change unit on *-by-size metrics to match bucket unit
authorMichael Anthony Knyszek <mknyszek@google.com>
Thu, 7 Jan 2021 17:24:39 +0000 (17:24 +0000)
committerMichael Knyszek <mknyszek@google.com>
Fri, 8 Jan 2021 16:28:15 +0000 (16:28 +0000)
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 <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Knyszek <mknyszek@google.com>

src/runtime/metrics.go
src/runtime/metrics/description.go
src/runtime/metrics/doc.go
src/runtime/metrics_test.go

index 4d37a56f4c9c9b1212c7bcf4c841bf5e9e1b5262..3e8dbda0cadf7112269625ed65f7301e8052455e 100644 (file)
@@ -86,7 +86,7 @@ func initMetrics() {
                                out.scalar = in.sysStats.gcCyclesDone
                        },
                },
-               "/gc/heap/allocs-by-size:objects": {
+               "/gc/heap/allocs-by-size:bytes": {
                        deps: makeStatDepSet(heapStatsDep),
                        compute: func(in *statAggregate, out *metricValue) {
                                hist := out.float64HistOrInit(sizeClassBuckets)
@@ -98,7 +98,7 @@ func initMetrics() {
                                }
                        },
                },
-               "/gc/heap/frees-by-size:objects": {
+               "/gc/heap/frees-by-size:bytes": {
                        deps: makeStatDepSet(heapStatsDep),
                        compute: func(in *statAggregate, out *metricValue) {
                                hist := out.float64HistOrInit(sizeClassBuckets)
index 32af5d172790050274995d3e731c4090bc538f80..01c8a685ee68259dd08ec7246ebe1dd3237d4dab 100644 (file)
@@ -23,6 +23,11 @@ type Description struct {
        // Examples of units might be "seconds", "bytes", "bytes/second", "cpu-seconds",
        // "byte*cpu-seconds", and "bytes/second/second".
        //
+       // For histograms, multiple units may apply. For instance, the units of the buckets and
+       // the count. By convention, for histograms, the units of the count are always "samples"
+       // with the type of sample evident by the metric's name, while the unit in the name
+       // specifies the buckets' unit.
+       //
        // A complete name might look like "/memory/heap/free:bytes".
        Name string
 
@@ -69,12 +74,12 @@ var allDesc = []Description{
                Cumulative:  true,
        },
        {
-               Name:        "/gc/heap/allocs-by-size:objects",
+               Name:        "/gc/heap/allocs-by-size:bytes",
                Description: "Distribution of all objects allocated by approximate size.",
                Kind:        KindFloat64Histogram,
        },
        {
-               Name:        "/gc/heap/frees-by-size:objects",
+               Name:        "/gc/heap/frees-by-size:bytes",
                Description: "Distribution of all objects freed by approximate size.",
                Kind:        KindFloat64Histogram,
        },
index a68184ee822c01f186f71c457f686a7bb87d70ec..021a0bddcaf3527b85a60a6e35bd807ad33f6c5e 100644 (file)
@@ -61,10 +61,10 @@ Below is the full list of supported metrics, ordered lexicographically.
        /gc/cycles/total:gc-cycles
                Count of all completed GC cycles.
 
-       /gc/heap/allocs-by-size:objects
+       /gc/heap/allocs-by-size:bytes
                Distribution of all objects allocated by approximate size.
 
-       /gc/heap/frees-by-size:objects
+       /gc/heap/frees-by-size:bytes
                Distribution of all objects freed by approximate size.
 
        /gc/heap/goal:bytes
index 5109058ed167f1a36881072f6aad6887865dea15..8a3cf019bdb474155b6daee86eee14d9cad00b39 100644 (file)
@@ -70,7 +70,7 @@ func TestReadMetrics(t *testing.T) {
                        checkUint64(t, name, samples[i].Value.Uint64(), mstats.BuckHashSys)
                case "/memory/classes/total:bytes":
                        checkUint64(t, name, samples[i].Value.Uint64(), mstats.Sys)
-               case "/gc/heap/allocs-by-size:objects":
+               case "/gc/heap/allocs-by-size:bytes":
                        hist := samples[i].Value.Float64Histogram()
                        // Skip size class 0 in BySize, because it's always empty and not represented
                        // in the histogram.
@@ -84,7 +84,7 @@ func TestReadMetrics(t *testing.T) {
                                        t.Errorf("histogram counts do not much BySize for class %d: got %d, want %d", i, c, m)
                                }
                        }
-               case "/gc/heap/frees-by-size:objects":
+               case "/gc/heap/frees-by-size:bytes":
                        hist := samples[i].Value.Float64Histogram()
                        // Skip size class 0 in BySize, because it's always empty and not represented
                        // in the histogram.
@@ -161,9 +161,9 @@ func TestReadMetricsConsistency(t *testing.T) {
                        totalVirtual.got = samples[i].Value.Uint64()
                case "/gc/heap/objects:objects":
                        objects.total = samples[i].Value.Uint64()
-               case "/gc/heap/allocs-by-size:objects":
+               case "/gc/heap/allocs-by-size:bytes":
                        objects.alloc = samples[i].Value.Float64Histogram()
-               case "/gc/heap/frees-by-size:objects":
+               case "/gc/heap/frees-by-size:bytes":
                        objects.free = samples[i].Value.Float64Histogram()
                case "/gc/cycles:gc-cycles":
                        gc.numGC = samples[i].Value.Uint64()