-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
statistics: replace StatsLoad mutex with a dedicated mutex for statsCache protection #59778
statistics: replace StatsLoad mutex with a dedicated mutex for statsCache protection #59778
Conversation
…ache protection Signed-off-by: Rustin170506 <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #59778 +/- ##
================================================
+ Coverage 72.9531% 73.5684% +0.6152%
================================================
Files 1699 1729 +30
Lines 469241 480686 +11445
================================================
+ Hits 342326 353633 +11307
+ Misses 105828 105087 -741
- Partials 21087 21966 +879
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…or statsCache protection Signed-off-by: Rustin170506 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR refactors mutex usage in the stats sync load logic by replacing the previously embedded mutex within StatsLoad with a dedicated mutex in statsSyncLoad to better protect the statsCache during concurrent updates.
- Introduces a dedicated mutex (mu) in statsSyncLoad.
- Updates updateCachedItem to use the new mutex.
- Removes the embedded mutex from the StatsLoad struct in types/interfaces.go.
Reviewed Changes
File | Description |
---|---|
pkg/statistics/handle/syncload/stats_syncload.go | Adds a dedicated mutex for protecting statsCache and updates lock usage |
pkg/statistics/handle/types/interfaces.go | Removes the now-unneeded embedded sync.Mutex from the StatsLoad struct |
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Signed-off-by: Rustin170506 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This PR refactors mutex usage for protecting the statistics cache by introducing a dedicated mutex in the statsSyncLoad struct and removing the embedded mutex from the StatsLoad type.
- Introduced a dedicated mutex "mu" in statsSyncLoad for better clarity on protecting statsCache.
- Replaced locking on StatsLoad with locking on the dedicated mutex in updateCachedItem.
- Removed the unused embedded mutex from the StatsLoad type in interfaces.
Reviewed Changes
File | Description |
---|---|
pkg/statistics/handle/syncload/stats_syncload.go | Added a dedicated mutex for statsCache protection and updated locking |
pkg/statistics/handle/types/interfaces.go | Removed an unnecessary embedded mutex from the StatsLoad type |
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
pkg/statistics/handle/syncload/stats_syncload.go:70
- [nitpick] Consider renaming 'mu' to 'statsCacheMu' for enhanced clarity regarding its purpose.
mu sync.Mutex
…tsCache updates Signed-off-by: Rustin170506 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔢 Self-check (PR reviewed by myself and ready for feedback.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AilinKid, elsa0520, qw4990 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What problem does this PR solve?
Issue Number: ref #55043
Problem Summary:
What changed and how does it work?
I moved the lock to the correct position because placing it near the two channels was too confusing.
Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.