-
Notifications
You must be signed in to change notification settings - Fork 103
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
Optimize normalization caching and copying #890
Optimize normalization caching and copying #890
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #890 +/- ##
==========================================
+ Coverage 61.03% 63.37% +2.34%
==========================================
Files 56 57 +1
Lines 5903 6029 +126
==========================================
+ Hits 3603 3821 +218
+ Misses 2143 2046 -97
- Partials 157 162 +5 ☔ View full report in Codecov by Sentry. |
7210af7
to
65a705b
Compare
Presubmit failure will be fixed by #891 |
Ready for review |
65a705b
to
89fb2cf
Compare
Would the code be significantly simpler if we could mutate? And are there any negative consequences of marking the exporter as mutating?
Could we wrap the pdata struct to hide this complexity to the caller? |
That might be a good idea to explore as well. It looks like it only matters if there are multiple exporters in the config: https://github.com/open-telemetry/opentelemetry-collector/blob/2166b11137ec473b01b6cc5a0b9bf932cb752cf2/internal/fanoutconsumer/metrics.go#L21. If there is only a single one, there is no additional clone involved. We already are doing a full clone for GMP anyways:
We probably could, but that is a lot of boilerplate. |
Lets try #892 first, and then see how much more of a benefit we get from some of the optimizations here. |
6236d55
to
a29cf5d
Compare
a29cf5d
to
a48768a
Compare
Ok, i've rebased this on the other change, and it now is much smaller. It still seems like a good improvement to make. |
Fixes #888
Changes
This avoids creating new cached elements, updates existing cached datapoints if they are already there, and only copies the required fields into the cache. In particular, not storing attributes lowers memory usage significantly. The benchmark difference is:
Note that this primarily improves the "reset" benchmarks. This is because we only store things in the cache when a reset happens. This is primarily capturing the fact that we are re-using data points, rather than making new ones.