refactor: convert route groups to a sync map#4966
Merged
ultrotter merged 7 commits intoprometheus:mainfrom Feb 11, 2026
Merged
Conversation
5396e06 to
4a15ffe
Compare
siavashs
reviewed
Feb 6, 2026
Contributor
siavashs
left a comment
There was a problem hiding this comment.
Looks great!
Just added a few comments.
siavashs
approved these changes
Feb 6, 2026
SoloJacobs
approved these changes
Feb 6, 2026
Contributor
SoloJacobs
left a comment
There was a problem hiding this comment.
Good enough for me. However, there is a commit missing from #4958 .
Contributor
Author
I know, but it rebases cleanly, so I was hoping github will happily rebase it once I merge that one :) |
2c3baf6 to
7870bac
Compare
Contributor
Author
Yes, I was waiting to finalize before rebasing! It's done now! |
added 7 commits
February 11, 2026 10:32
This allows us to avoid taking the lock in most cases. The exception is that we still need it when adding an aggrgroup, as multiple goroutines might be otherwise trying to add theirs, for the same fp. Signed-off-by: Guido Trotter <guido@hudson-trading.com>
…ion when the map is dirty Signed-off-by: Guido Trotter <guido@hudson-trading.com>
Use sync map swap operations, with max retries, to avoid one extra lock. Signed-off-by: Guido Trotter <guido@hudson-trading.com>
This allows us to allocate the right amount of memory when we read them for Groups(). The number may not be precise, but will work in most cases. Signed-off-by: Guido Trotter <guido@hudson-trading.com>
…e copy extra size Signed-off-by: Guido Trotter <guido@hudson-trading.com>
Signed-off-by: Guido Trotter <guido@hudson-trading.com>
- just pass a DestroyIfEmpty value to DeleteIfNotModified - never destroy in GC Signed-off-by: Guido Trotter <guido@hudson-trading.com>
6aa74a7 to
a5cb389
Compare
SoloJacobs
pushed a commit
to SoloJacobs/alertmanager
that referenced
this pull request
Mar 15, 2026
* [dispatcher] Convert groups to a sync map This allows us to avoid taking the lock in most cases. The exception is that we still need it when adding an aggrgroup, as multiple goroutines might be otherwise trying to add theirs, for the same fp. Signed-off-by: Guido Trotter <guido@hudson-trading.com> * Even with sync map snapshot the groups in each route to avoid contention when the map is dirty Signed-off-by: Guido Trotter <guido@hudson-trading.com> * Remove lock outside of the per route sync.Map Use sync map swap operations, with max retries, to avoid one extra lock. Signed-off-by: Guido Trotter <guido@hudson-trading.com> * keep groups len in routeAggrGroups This allows us to allocate the right amount of memory when we read them for Groups(). The number may not be precise, but will work in most cases. Signed-off-by: Guido Trotter <guido@hudson-trading.com> * Use a constant instead of the concurrency field for the Groups() slice copy extra size Signed-off-by: Guido Trotter <guido@hudson-trading.com> * cast sync.Map Range value to aggrGroup only once Signed-off-by: Guido Trotter <guido@hudson-trading.com> * Remove 'dontdestroy' property of the alert store - just pass a DestroyIfEmpty value to DeleteIfNotModified - never destroy in GC Signed-off-by: Guido Trotter <guido@hudson-trading.com> --------- Signed-off-by: Guido Trotter <guido@hudson-trading.com> Co-authored-by: Guido Trotter <guido@hudson-trading.com>
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.
This allows us to avoid taking the lock in most cases.
The exception is that we still need it when adding an aggrgroup, as multiple goroutines might be otherwise trying to add theirs, for the same fp.
This applies on top of #4958