-
Notifications
You must be signed in to change notification settings - Fork 504
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
Implement Hasheable Float for use in metrics #1780
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1780 +/- ##
=====================================
Coverage 73.0% 73.1%
=====================================
Files 121 121
Lines 18891 18923 +32
=====================================
+ Hits 13808 13842 +34
+ Misses 5083 5081 -2 ☔ View full report in Codecov by Sentry. |
Sorry haven't get a chance to look at it. Will do it today |
Moved to draft for now, as other changes are likely conflicting with this PR. and I'd prefer to finish those first and comeback to this. Also, I modified this PR so that the hash/eq implementations are restricted to "metrics" feature flag only in api. |
@utpilla and I discussed another alternative option - for Metrics, if the Attribute's value is |
Creating a |
That should be a one-time allocation (only when storing the key-value pair on the Hashmap), right?
Is it even possible to have a float value stringified to "1.0" or "1.00"? Shouldn't it be just converted to "1"? let num1: f64 = 1.0;
let num2: f64 = 1.00;
assert_eq!("1", num1.to_string());
assert_eq!("1", num2.to_string()); |
what is the issue with having bitwise hashing? Apart from performance, it would be good to test that there is no precision loss in conversion from the float to string. |
Good point you are right. Display implementation will do some conversion before stringify it |
+1 It's not clear to me what benifit the stringify brings compare with bitwise hashing? |
The overhead is on f64 -> string, which happens for every hash of
|
🤣 Now I am not sure. I was trying to avoid having to own the hashing logic ourselves, and steer users away from using float for dimension values in the first place! (No metric backend that I am aware of support float dimension values, it'll be anyway stringified at exporter/ingestion level) I'll stick the bitwise hashing for now, and also include a note/warning for users to avoid f64 values for Metric KeyValues. |
yes the cost if not one time, it is ongoing for all measurements. |
@TommyCpp I know we are not considering this anymore but just for my own learning, I think it probably doesn't have to do stringification. I believe the in-memory representation of the float values let num1: f64 = 1.0;
let num2: f64 = 1.00;
println!("{}", num1.to_bits()); // 4607182418800017408
println!("{}", num2.to_bits()); // 4607182418800017408
assert_eq!(num1.to_bits(), num2.to_bits()); |
Closing in favor of #1806 |
Yep they should have the same underlying representation right after compiling from literal value to f64 |
Towards #1761
This adds Hash implementation for KeyValue, by providing a wrapper around F64. This is only planned to be used in Metrics aggregation.
HashKeyValue is replaces with KeyValue in sdk.
Alternatively, we could just state that float values in attributes for Metrics are not supported. It was never tested before either!
No perf regression, but slight gains, probably due to one less indirection?.