-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
metric: remove mutex around windowed histogram update
Previously, we used an `RWMutex` to serialize access to the windowed histogram. This was done because there's a rotation that needs to happen that moves the currently active histogram into the `prev` variable and creates a fresh one to update in `cur`. This is done to maintain the window. This change limits the mutex usage to rotation and window snapshotting, removing the need to take a read lock during updates since we can atomically grab the `cur` histogram. There's a bit of nuance to manage around the fact that `prev` can be nil on the first iteration, since `cur` is the first histogram. After a single rotation, `prev` will not be nil again. The prometheus histogram itself (what's stored in the `atomic.Value`) is thread-safe. Part of #133306 Release note: None
- Loading branch information
1 parent
507c68f
commit ff9dd52
Showing
3 changed files
with
28 additions
and
36 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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