-
Notifications
You must be signed in to change notification settings - Fork 476
Base2 exponential histogram aggregation #3346
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
Base2 exponential histogram aggregation #3346
Conversation
|
✅ Deploy Preview for opentelemetry-cpp-api-docs canceled.
|
@lalitb @ThomsonTan @marcalff @dbarker In order to satisfy CLA check had to remove some @{corporate}.com alias from the commit history by using a new branch. I am closing the previous WIP PR and @felipesantosk and I will be working here. Looking forward to your review and comments :) |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3346 +/- ##
==========================================
+ Coverage 89.55% 89.67% +0.12%
==========================================
Files 210 211 +1
Lines 6505 6832 +327
==========================================
+ Hits 5825 6126 +301
- Misses 680 706 +26
🚀 New features to boost your workflow:
|
examples/otlp/grpc_metric_main.cc
Outdated
|
||
histogram_aggregation_config->max_scale_ = 3; | ||
|
||
// histogram_aggregation_config->boundaries_ = std::vector<double>{ |
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.
Is the boundary configuration still needed? Remove it if no.
HistogramPointData, | ||
Base2ExponentialHistogramPointData, | ||
LastValuePointData, | ||
DropPointData>; |
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.
Did a quick test on the effect of adding a Base2ExponentialHistogramPointData
as new variant alternative. As the size of a variant type is determined by the size of its largest alternative, there seems to increase in ~50 bytes per aggregated value. For the maximum cardinality limit of 2000, this would account for 100KB worst scenario peek increase per configured instrument.
Refer - https://godbolt.org/z/cG6b6Ks1d
output:
sizeof(PointTypeWithBase2): 176 bytes
sizeof(PointTypeWithoutBase2): 120 bytes
I believe this increase is reasonable, unless there are specific concerns about memory usage at scale - with large number of configured instruments. @ThomsonTan ?
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.
Thanks for trying this. This extra memory consumption could be an issue for the users who are not using exponential histogram, as we've seen some user have very large number of instruments configured. @ethandmd , is it possible to make the feature opt-in to avoid taking the extra memory for users who don't use this feature?
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.
We can also modify the Base2ExponentialHistogramPointData
to contain unique_ptr to AdaptingCircularBufferCounter
, as that seems to be inflating the size. Something like:
class Base2ExponentialHistogramPointDataUniquePtr {
public:
uint64_t count_{};
double sum_{};
int32_t scale_{};
uint64_t zero_count_{};
std::unique_ptr<AdaptingCircularBufferCounter> positive_buckets_;
std::unique_ptr<AdaptingCircularBufferCounter> negative_buckets_;
double min_{}, max_{}, zero_threshold_{};
bool record_min_max_ = true;
size_t max_buckets_{};
Base2ExponentialHistogramPointDataUniquePtr()
: positive_buckets_{std::make_unique<AdaptingCircularBufferCounter>(0)},
negative_buckets_{std::make_unique<AdaptingCircularBufferCounter>(0)} {}
};
The size seems to be reduced to the earlier size with that: - https://godbolt.org/z/zvdbfYYbs
sizeof(PointTypeWithBase2): 176 bytes
sizeof(PointTypeWithoutBase2): 120 bytes
sizeof(PointTypeWithBase2UniquePtr): 120 bytes
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.
Thanks for the analysis! Let me take a look
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.
One more suggestion is moving below 2 files together and put them at the end of the class, which will make the padding more compact.
int32_t scale_{};
bool record_min_max_ = true;
sdk/src/metrics/aggregation/base2_exponential_histogram_aggregation.cc
Outdated
Show resolved
Hide resolved
sdk/src/metrics/aggregation/base2_exponential_histogram_aggregation.cc
Outdated
Show resolved
Hide resolved
…ation.cc Co-authored-by: Tom Tan <[email protected]>
Propose change in follow up PR
Fixes #1391
Changes
Add base2 exponential histogram aggregation.
For significant contributions please make sure you have completed the following items:
CHANGELOG.md
updated for non-trivial changes