Merged
Conversation
…for all sub-series instead of during each collection
zalegrala
approved these changes
Oct 24, 2024
Contributor
zalegrala
left a comment
There was a problem hiding this comment.
Looks good. I appreciate the TODOs also.
| return nil | ||
| } | ||
|
|
||
| func BenchmarkPushSpans(b *testing.B) { |
Contributor
There was a problem hiding this comment.
I love the full stack benchmark. This is something we might want to do for other components as well.
| } | ||
|
|
||
| b.StopTimer() | ||
| runtime.GC() |
Contributor
There was a problem hiding this comment.
Why force a GC after the benchmark has been timed? Is this to avoid impact on later benchmarks, or to get accurate memory summary below?
Contributor
Author
There was a problem hiding this comment.
In this case I was trying to see if the benchmarks could help measure inuse memory, so it is recording HeapInUse at the bottom. Without the GC it just keeps growing in between runs of the benchmark (-count=5 for example). So this was an attempt to make the inuse metric more useful.
3 tasks
knylander-grafana
pushed a commit
that referenced
this pull request
Oct 29, 2024
* todos * more todos and print inuse stats * Benchmark report heapinuse, ensure cleanup between benchmarks * Improve memory usage by changing histograms to precompute all labels for all sub-series instead of during each collection * changelog
This was referenced Nov 1, 2024
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does:
Metrics generator span metrics and service graphs are very popular, but memory usage can be quite high for high-cardinality setups, for example 1+ million active series in a single pod. I noticed some areas for improvement to reduce memory.
This PR contains 2 updates:
(1) on the surface it updates histograms to pre-compute all prometheus labels during creation, instead of during collection time. This way we alloc the labels once instead of on every scrape. This is possible because all of the labels for a specific histogram bucket are fixed, even external labels which are configured via runtime config.
(2) Almost more importantly in mind, it's adding a suite of benchmarks for the generator, which include WAL and non-mock registry. These benchmarks will help us identify more improvements like (1). Skimming through the module I've left several TODOs large and small of next areas to update.
Benchmarks show a large reduction in mem in Collect. Tested this in an internal cluster and it was ~15% total working set savings.
Which issue(s) this PR fixes:
Fixes #
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]