From 87eda2a782db9b7ad2ec1fd335ed6c7472aa66bc Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Tue, 30 Aug 2022 03:13:36 +0000 Subject: runtime: shrink time histogram buckets There are lots of useless buckets with too much precision. Introduce a minimum level of precision with a minimum bucket bit. This cuts down on the size of a time histogram dramatically (~3x). Also, pick a smaller sub bucket count; we don't need 6% precision. Also, rename super-buckets to buckets to more closely line up with HDR histogram literature. Change-Id: I199449650e4b34f2a6dca3cf1d8edb071c6655c0 Reviewed-on: https://go-review.googlesource.com/c/go/+/427615 Run-TryBot: Michael Knyszek Auto-Submit: Michael Knyszek TryBot-Result: Gopher Robot Reviewed-by: Michael Pratt --- src/runtime/export_test.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/runtime/export_test.go') diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index c29d64a885..93cae48211 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -1228,22 +1228,28 @@ func MSpanCountAlloc(ms *MSpan, bits []byte) int { } const ( - TimeHistSubBucketBits = timeHistSubBucketBits - TimeHistNumSubBuckets = timeHistNumSubBuckets - TimeHistNumSuperBuckets = timeHistNumSuperBuckets + TimeHistSubBucketBits = timeHistSubBucketBits + TimeHistNumSubBuckets = timeHistNumSubBuckets + TimeHistNumBuckets = timeHistNumBuckets + TimeHistMinBucketBits = timeHistMinBucketBits + TimeHistMaxBucketBits = timeHistMaxBucketBits ) type TimeHistogram timeHistogram // Counts returns the counts for the given bucket, subBucket indices. // Returns true if the bucket was valid, otherwise returns the counts -// for the underflow bucket and false. -func (th *TimeHistogram) Count(bucket, subBucket uint) (uint64, bool) { +// for the overflow bucket if bucket > 0 or the underflow bucket if +// bucket < 0, and false. +func (th *TimeHistogram) Count(bucket, subBucket int) (uint64, bool) { t := (*timeHistogram)(th) - i := bucket*TimeHistNumSubBuckets + subBucket - if i >= uint(len(t.counts)) { + if bucket < 0 { return t.underflow.Load(), false } + i := bucket*TimeHistNumSubBuckets + subBucket + if i >= len(t.counts) { + return t.overflow.Load(), false + } return t.counts[i].Load(), true } -- cgit v1.3-5-g9baa