-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Remove unnecessary lock from count() method #4352
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Anand Rajagopal <[email protected]>
This seems reasonable to me. Have you tested it with the race detector just out of interest? |
Do you mean the following?
|
Not the tests, but run a build Alertmanager of with this patch with the race detector enabled. |
Will do this and report back |
I built AM with |
The count() acquires a lock but it is not necessary. The method makes a copy of store alerts by calling
a.alerts.List()
. Thea.alerts.List()
method acquires its own internal lockSimilarly,
a.marker.Status(..)
also has its own lock. Therefore, removing the lock fromcount()
should be safe.count()
method is called during scrapes and since it acquires a lock, it can cause bottlenecks during scraping