Skip to content
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

Preallocate and keep memory for HashMap in Metric aggregation #2343

Merged

Conversation

cijothomas
Copy link
Member

Discussed originally in #2267 (comment)
and in #2288 (comment)

2 changes

  1. HashMap for aggregations are created with enough capacity to hold cardinality. (Its currently hardcoded, but will be configurable later)
  2. Delta - during collect, the hashmap is swapped with a secondary hashmap., and the original is drained.

These ensures HashMap never requires re-sizing in its lifetime.

Incremental changes only, as this is not quite the final state - we'll need to likely store the overflow outside of hashmap and also tackle #2328

@cijothomas cijothomas requested a review from a team as a code owner November 26, 2024 00:28
Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 82.35294% with 3 lines in your changes missing coverage. Please review.

Project coverage is 79.5%. Comparing base (9a85ce1) to head (759f2a7).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
opentelemetry-sdk/src/metrics/internal/mod.rs 81.2% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##            main   #2343     +/-   ##
=======================================
- Coverage   79.5%   79.5%   -0.1%     
=======================================
  Files        123     123             
  Lines      21365   21371      +6     
=======================================
+ Hits       17004   17008      +4     
- Misses      4361    4363      +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

stress/Cargo.toml Outdated Show resolved Hide resolved
@cijothomas cijothomas added this to the 0.27.1 milestone Nov 26, 2024
@cijothomas cijothomas merged commit c9388e4 into open-telemetry:main Nov 26, 2024
20 of 21 checks passed
@cijothomas cijothomas deleted the cijothomas/metric-pre-allocation branch November 26, 2024 18:25
pitoniak32 pushed a commit to pitoniak32/opentelemetry-rust that referenced this pull request Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants