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

Fix unbounded memory growth with perfmaps/JIT dumps #2265

Merged
merged 2 commits into from
Nov 20, 2023
Merged

Fix unbounded memory growth with perfmaps/JIT dumps #2265

merged 2 commits into from
Nov 20, 2023

Conversation

brancz
Copy link
Member

@brancz brancz commented Nov 20, 2023

Why?

We have seen unbounded growth of memory in customer environments in JITed scenarios where perfmaps/jitdumps are used.

What?

The memory usage of this code path is entirely held by newStringConverter and Deduplicate: https://pprof.me/c801111f0576cba2f7dc3feb77ad7008/?profileType=profile%3Ainuse_space%3Abytes%3Aspace%3Abytes&filter_by_function=github.com%2Fparca-dev%2Fparca-agent%2Fpkg%2Fperf.ReadPerfMap&search_string=github.com%2Fparca-dev%2Fparca-agent%2Fpkg%2Fperf.ReadPerfMap

How?

This patch replaces the string converter with a string dictionary to reduce memory usage caused by duplicate strings, and compacts it together with the deduplicated perfmap entries, which previously were holding however many entries were in the perfmap, even if the majority was deduplicated.

Test Plan

Unit tests are passing and we ultimately have to test this in customer environments as it can only be observed in long-running environments.

Further notes

If this is not good enough, ultimately the perfmap should be read from the bottom up to never even load "outdated" entries in the first place, I'd only want to implement that though if this doesn't already fix things.

If do do go down that route these two would be helpful:

@brancz brancz merged commit 265139c into main Nov 20, 2023
22 checks passed
@brancz brancz deleted the mem-growth branch November 20, 2023 14:18
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.

2 participants