-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
metrics: Improve flexibility of H2Histogram Configuration #6963
base: master
Are you sure you want to change the base?
Conversation
Based on feedback tokio-rs#6960, customers want more flexibility in histogram configuration. The main change here is allowing precision for an H2 Histgoram to go all the way down to zero—there is not fundamental reason this wasn't possible before, but typically H2 histograms stop at P=2. I've also added another optimization that truncates the number of buckets based on the requested max_value. This can save space by truncating in the middle of a bucket group. Along the way and in the process of adding more tests, I found a couple of bugs which are fixed here: 1. The `max_value` in LogHistogramBuilder wasn't precisely respected 2. The `max_value` computed by `LogHistogram` was actually incorrect for some n/p combinations. The new version precisely considers bucket layout instead.
tokio/tests/rt_unstable_metrics.rs
Outdated
for b in 0..num_buckets { | ||
let range = metrics.poll_time_histogram_bucket_range(b); | ||
let size = range.end - range.start; | ||
println!("bucket {b}: {range:?} (size: {size:?})"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we assert their values here instead of printing?
panic!("precision must be >= 2"); | ||
}; | ||
if p > 10 { | ||
if p > MAX_PRECISION { | ||
panic!("precision must be <= 10"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
panic!("precision must be <= 10"); | |
panic!("precision must be <= {}", MAX_PRECISION); |
/// To match the behavior of the previous log histogram implementation, use | ||
/// `builder.precision_exact(0)`. This creates a histogram where each bucket is twice the size | ||
/// of the previous value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd revert the order of this sentence so you first say that passing 0 results in buckets with doubling being used for the size, and then you can comment that this matches the behavior used in the legacy implementation.
@@ -1245,8 +1245,30 @@ impl Builder { | |||
/// .unwrap(); | |||
/// ``` | |||
/// | |||
/// Configure a `LogHistogram` with similar behavior to [`HistogramScale::Log`] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence is confusing. I'm guessing HistogramScale::Log
is the old implementation?
/// ```rust | ||
/// |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// ```rust | |
/// | |
/// ```rust |
prop_assert!(last_bucket_start > max_value, "last bucket start ({last_bucket_start:?} must be at least as big as `max_value` ({max_value:?})"); | ||
|
||
// We should have the exact right number of buckets. The second to last bucket should be strictly less than max value. | ||
prop_assert!(second_last_bucket_start < max_value, "second last bucket end ({second_last_bucket_start:?} must be at least as big as `max_value` ({max_value:?})"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: long lines, perhaps this could be manually split up?
if p > MAX_PRECISION { | ||
panic!("precision must be <= 10"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is from the previous commit, but perhaps this could be an assert instead, that's how pre-conditions are mostly checked in tokio.
Any status update on this? |
Sorry I went on parental leave, I will have someone from my team follow up
…On Thu, Nov 21, 2024, 11:29 AM Alice Ryhl ***@***.***> wrote:
Any status update on this?
—
Reply to this email directly, view it on GitHub
<#6963 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AADYKZ73MH7JJPJLKHMEDML2BYC7VAVCNFSM6AAAAABRNWIB2OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDIOJRG4YDSMZRGM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Congratulations!! |
Motivation
Based on feedback #6960, customers want more flexibility in histogram configuration.
The main change here is allowing precision for an H2 Histgoram to go all the way down to zero—there is not fundamental reason this wasn't possible before, but typically H2 histograms stop at P=2.
Solution
I've also added another optimization that truncates the number of buckets based on the requested max_value. This can save space by truncating in the middle of a bucket group.
Along the way and in the process of adding more tests, I found a couple of bugs which are fixed here:
max_value
in LogHistogramBuilder wasn't precisely respectedmax_value
computed byLogHistogram
was actually incorrect for some n/p combinations. The new version precisely considers bucket layout instead.