-
Notifications
You must be signed in to change notification settings - Fork 440
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
[SDK] Added reserve for spans array in BatchSpanProcessor. #2724
Conversation
Added reserve for spans array in BatchSpanProcessor. Helps to allocate the amount of memory needed for number of records so that dynamic memory allocation doesn't happen in the consume method. .push_back() reallocates memory each time the method is called. Using .reserve() would avoid memory reallocation as already the memory is allocated. References: https://cplusplus.com/reference/vector/vector/push_back/ https://cplusplus.com/reference/vector/vector/reserve/
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2724 +/- ##
==========================================
+ Coverage 87.12% 87.67% +0.56%
==========================================
Files 200 190 -10
Lines 6109 5855 -254
==========================================
- Hits 5322 5133 -189
+ Misses 787 722 -65
|
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.
Looks good to me, thanks for the fix.
See the suggested change to fix the CI failure on code format.
Co-authored-by: Marc Alff <marc.alff@free.fr>
Thanks for suggesting. I think CI Checks should starting running now. |
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,
Similar change can be done for BatchLogProcessor. @msiddhu just in case you can handle as separate as same PR :) |
Added reserve for spans array in BatchLogProcessor. Same as previously done for BatchSpanProcessor
Thanks for pointing out. Made the suggested changes. Please review. |
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.
LGTM, thanks for the fix.
[SDK] Added reserve for spans array in BatchSpanProcessor. (open-telemetry#2724)
Changes
Added
.reserve
forspans_arr
in BatchSpanProcessor (Small Optimization)Helps to allocate the amount of memory needed for number of records so that dynamic memory allocation doesn't happen in the consume method.
.push_back()
reallocates memory each time the method is called.Using
.reserve()
would avoid memory reallocation as already the memory is allocated.References:
C++ Vector push_back
C++ Vector reserve
CHANGELOG.md
updated for non-trivial changes