Skip to content

Preallocate a map of the right size in pcommon Map.AsRaw() #12406

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

Merged
merged 3 commits into from
Feb 24, 2025

Conversation

kamstrup
Copy link
Contributor

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: bogdandrutu / name: Bogdan Drutu (305c92d)
  • ✅ 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.10%. Comparing base (cffb7b6) to head (305c92d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #12406   +/-   ##
=======================================
  Coverage   92.10%   92.10%           
=======================================
  Files         465      465           
  Lines       25180    25180           
=======================================
  Hits        23191    23191           
  Misses       1592     1592           
  Partials      397      397           

☔ 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
Contributor 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
Contributor 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

@bogdandrutu bogdandrutu added this pull request to the merge queue Feb 24, 2025
Merged via the queue into open-telemetry:main with commit 362db71 Feb 24, 2025
54 checks passed
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