diff options
| author | Michael Anthony Knyszek <mknyszek@google.com> | 2022-08-30 03:13:36 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-09-16 16:32:01 +0000 |
| commit | 87eda2a782db9b7ad2ec1fd335ed6c7472aa66bc (patch) | |
| tree | ddce2915a770b3fa37fac8410352924a47055cfb /src/runtime/export_test.go | |
| parent | 1fc83690e68de1ce252975c5fd3a232629d6a3d6 (diff) | |
| download | go-87eda2a782db9b7ad2ec1fd335ed6c7472aa66bc.tar.xz | |
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 <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/export_test.go')
| -rw-r--r-- | src/runtime/export_test.go | 20 |
1 files changed, 13 insertions, 7 deletions
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 } |
