mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
1fc83690e6
commit
87eda2a782
4 changed files with 162 additions and 131 deletions
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue