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

Don't rebuild textfile metricsfamily help text for the same name every time #3175

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

mknapphrt
Copy link
Contributor

This "optimization" shouldn't really be necessary in 99.99..% cases, but we recently ran into a memory usage issue because we had a huge number of processes dumping a few of the same metrics into their own textfile collector paths. Because this builds a help text for metricsfamily that is comprised of the names of all files with that same metric, this blew up the memory usage of building and storing all those help texts. So this change caches the help text for a given mf.Name, and doesn't recompute/store it every time.

To test the memory usage change, I dumped 5000 textfiles into a directory, and checked the process memory usage with and without this change. Before the change, node exporter reported process_resident_memory_bytes 3.608977408e+09, or >3G of memory. After this it was only process_resident_memory_bytes 3.0969856e+07, or ~30M.

Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@SuperQ SuperQ merged commit 0fddfd1 into prometheus:master Nov 7, 2024
7 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.

2 participants