mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: fix allocs-by-size and frees-by-size buckets
Currently these two metrics are reported incorrectly, going by the documentation in the runtime/metrics package. We just copy in the size-class-based values from the runtime wholesale, but those implicitly have an inclusive upper-bound and exclusive lower-bound (e.g. 48-byte size class contains objects in the size range (32, 48]) but the API declares inclusive lower-bounds and exclusive upper-bounds. Also, the bottom bucket representing (-inf, 1) should always be empty. Extend the consistency check to verify this. Updates #43329. Change-Id: I11b5b062a34e13405ab662d15334bda91f779775 Reviewed-on: https://go-review.googlesource.com/c/go/+/279467 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
parent
fb96f07e1a
commit
8db7e2fecd
2 changed files with 18 additions and 1 deletions
|
|
@ -154,6 +154,12 @@ func TestReadMetricsConsistency(t *testing.T) {
|
|||
if totalVirtual.got != totalVirtual.want {
|
||||
t.Errorf(`"/memory/classes/total:bytes" does not match sum of /memory/classes/**: got %d, want %d`, totalVirtual.got, totalVirtual.want)
|
||||
}
|
||||
if objects.alloc.Counts[0] > 0 {
|
||||
t.Error("found counts for objects of non-positive size in allocs-by-size")
|
||||
}
|
||||
if objects.free.Counts[0] > 0 {
|
||||
t.Error("found counts for objects of non-positive size in frees-by-size")
|
||||
}
|
||||
if len(objects.alloc.Buckets) != len(objects.free.Buckets) {
|
||||
t.Error("allocs-by-size and frees-by-size buckets don't match in length")
|
||||
} else if len(objects.alloc.Counts) != len(objects.free.Counts) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue