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 a map of the right size in pcommon Map.AsRaw() #12406

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kamstrup
Copy link

Description

We are seeing pcommon/Map.AsRaw() show up in the memory profiles.

This PR ensure we pre-allocate a map[string]any of the expected size, instead of just an empty map.

@kamstrup kamstrup requested review from bogdandrutu, dmitryax and a team as code owners February 17, 2025 15:02
Copy link

linux-foundation-easycla bot commented Feb 17, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: kamstrup / name: Mikkel Kamstrup Erlandsen (0dabdfb, e0578fa)

@bogdandrutu
Copy link
Member

This PR is ok, but I am curious why do you need to call this function and in which component?

Copy link

codecov bot commented Feb 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.19%. Comparing base (a567a01) to head (0dabdfb).
Report is 20 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12406      +/-   ##
==========================================
+ Coverage   91.55%   92.19%   +0.64%     
==========================================
  Files         467      465       -2     
  Lines       25652    25285     -367     
==========================================
- Hits        23485    23311     -174     
+ Misses       1768     1575     -193     
  Partials      399      399              

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

@bogdandrutu
Copy link
Member

bogdandrutu commented Feb 17, 2025

Please add a changelog entry

@github-actions github-actions bot requested a review from bogdandrutu February 19, 2025 13:50
@kamstrup
Copy link
Author

Please add a changelog entry

Done :-)

@bogdandrutu
Copy link
Member

@kamstrup ping on

but I am curious why do you need to call this function and in which component?

@kamstrup
Copy link
Author

@kamstrup ping on

but I am curious why do you need to call this function and in which component?

Good question :-) We have custom storage engine and we do some massaging of otel payloads to store them most efficiently. We pull the attributes out as a map and rearrange the data.

When we have huge nested maps AsRaw starts to show up in the profiles. Not a deal breaker by any means, of course, but just thought it was a nice small improvement

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