-
Notifications
You must be signed in to change notification settings - Fork 725
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: add gc in hot peer cache #8702
Conversation
Signed-off-by: lhy1024 <[email protected]>
Signed-off-by: lhy1024 <[email protected]>
Signed-off-by: lhy1024 <[email protected]>
Signed-off-by: lhy1024 <[email protected]>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #8702 +/- ##
==========================================
+ Coverage 75.56% 75.59% +0.03%
==========================================
Files 460 460
Lines 72107 72135 +28
==========================================
+ Hits 54489 54534 +45
+ Misses 14126 14108 -18
- Partials 3492 3493 +1
Flags with carried forward coverage won't be shown. Click here to find out more. |
pkg/statistics/hot_peer_cache.go
Outdated
@@ -115,6 +116,7 @@ func (f *HotPeerCache) UpdateStat(item *HotPeerStat) { | |||
return | |||
} | |||
f.incMetrics(item.actionType, item.StoreID) | |||
f.removeExpiredItems() |
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.
Will it be called every time we receive a region heartbeat?
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.
In previous, removeItem
or putItem
will call tn.maintain()
every time. In this PR, it will call only after topNTTL
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.
L554-L556
pkg/statistics/hot_cache.go
Outdated
@@ -80,7 +80,7 @@ func (w *HotCache) CheckReadAsync(task func(cache *HotPeerCache)) bool { | |||
func (w *HotCache) RegionStats(kind utils.RWType, minHotDegree int) map[uint64][]*HotPeerStat { | |||
ret := make(chan map[uint64][]*HotPeerStat, 1) | |||
collectRegionStatsTask := func(cache *HotPeerCache) { | |||
ret <- cache.RegionStats(minHotDegree) | |||
ret <- cache.PeerStats(minHotDegree) |
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.
Why change the name, it's not consistent with other places.
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.
Okay, I'll keep the TODO and change them in another PR uniform.
/check-issue-triage-complete |
Signed-off-by: lhy1024 <[email protected]>
Signed-off-by: lhy1024 <[email protected]>
pkg/statistics/utils/topn_test.go
Outdated
@@ -217,6 +217,7 @@ func TestTTL(t *testing.T) { | |||
} | |||
re.True(tn.Put(item)) | |||
} | |||
tn.RemoveExpired() |
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.
Please check the return.
pkg/statistics/hot_peer_cache.go
Outdated
@@ -548,6 +551,36 @@ func (f *HotPeerCache) removeItem(item *HotPeerStat) { | |||
} | |||
} | |||
|
|||
func (f *HotPeerCache) removeExpiredItems() { |
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.
How about renaming to gc()
?
Signed-off-by: lhy1024 <[email protected]>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: okJiang, rleungx 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 |
close tikv#8698 Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
Signed-off-by: lhy1024 <[email protected]>
close #8698 Signed-off-by: lhy1024 <[email protected]> Co-authored-by: lhy1024 <[email protected]>
close tikv#8698 Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
close #8698 Signed-off-by: ti-chi-bot <[email protected]> Signed-off-by: lhy1024 <[email protected]> Co-authored-by: lhy1024 <[email protected]> Co-authored-by: lhy1024 <[email protected]> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
close tikv#8698 Signed-off-by: ti-chi-bot <[email protected]>
In response to a cherrypick label: new pull request created to branch |
close #8698 Signed-off-by: ti-chi-bot <[email protected]> Signed-off-by: lhy1024 <[email protected]> Co-authored-by: lhy1024 <[email protected]> Co-authored-by: lhy1024 <[email protected]> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
What problem does this PR solve?
Issue Number: Close #8698
What is changed and how does it work?
Check List
Tests
Release note