Scraping: optimise sync of targets#12048
Merged
bboreham merged 6 commits intoprometheus:mainfrom Mar 9, 2023
Merged
Conversation
`loadConfiguration` is made more general. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Member
Author
|
Rebased on master and added another optimisation, which is a breaking change to the interface of |
This lets relabelling work on a `Builder` rather than converting to and from `Labels` on every rule. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Save work converting between Builder and Labels. Also expose ProcessBuilder, so callers can supply a Builder. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Save work converting to and fro. Uses the recently-added relabel.ProcessBuilder variant. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Save work converting to `Labels` then to `Builder`. `PopulateLabels()` now takes as Builder as input. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Common service discovery mechanisms such as Kubernetes can generate a lot of target groups, so this function was allocating a lot of memory which then immediately became garbage. Re-using the structures across an entire Sync saves effort. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
Member
|
Thank you! I like how you used a for loop with |
roidelapluie
approved these changes
Mar 8, 2023
Member
Author
That's in #12084 |
This was referenced Mar 9, 2023
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.
Scraping targets are synced by creating the full set, then adding/removing any which have changed.
This PR speeds up the process of creating the full set.
I added a benchmark for
TargetsFromGroup; it uses configuration from a typical Kubernetes SD.The crux of the change is to do relabeling inside
labels.Builderinstead of converting tolabels.Labelsand back again for every rule. The change is broken into several commits for easier review.This is a breaking change to
scrape.PopulateLabels(), butrelabel.Processis left as-is, with a newrelabel.ProcessBuilderoption.Benchmarks, first with the slice version of
labels.Labels:and then with
-tags stringlabels: