Skip to content
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

Merged
merged 7 commits into from
Oct 28, 2024
Merged

statistics: add gc in hot peer cache #8702

merged 7 commits into from
Oct 28, 2024

Conversation

lhy1024
Copy link
Contributor

@lhy1024 lhy1024 commented Oct 14, 2024

What problem does this PR solve?

Issue Number: Close #8698

What is changed and how does it work?

Check List

Tests

  • Unit test

Release note

None.

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 14, 2024
Signed-off-by: lhy1024 <[email protected]>
Signed-off-by: lhy1024 <[email protected]>
Signed-off-by: lhy1024 <[email protected]>
Copy link

codecov bot commented Oct 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.59%. Comparing base (988c9a3) to head (9481fb7).
Report is 56 commits behind head on master.

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     
Flag Coverage Δ
unittests 75.59% <100.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

@lhy1024 lhy1024 requested a review from rleungx October 16, 2024 06:47
@@ -115,6 +116,7 @@ func (f *HotPeerCache) UpdateStat(item *HotPeerStat) {
return
}
f.incMetrics(item.actionType, item.StoreID)
f.removeExpiredItems()
Copy link
Member

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?

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

L554-L556

@@ -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)
Copy link
Member

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.

Copy link
Contributor Author

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.

@lhy1024
Copy link
Contributor Author

lhy1024 commented Oct 22, 2024

/check-issue-triage-complete

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Oct 22, 2024
@@ -217,6 +217,7 @@ func TestTTL(t *testing.T) {
}
re.True(tn.Put(item))
}
tn.RemoveExpired()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check the return.

@@ -548,6 +551,36 @@ func (f *HotPeerCache) removeItem(item *HotPeerStat) {
}
}

func (f *HotPeerCache) removeExpiredItems() {
Copy link
Member

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]>
@ti-chi-bot ti-chi-bot bot added the lgtm label Oct 25, 2024
Copy link
Contributor

ti-chi-bot bot commented Oct 25, 2024

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Oct 25, 2024
Copy link
Contributor

ti-chi-bot bot commented Oct 25, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-10-22 08:00:06.328372797 +0000 UTC m=+338007.025163402: ☑️ agreed by rleungx.
  • 2024-10-25 14:52:16.860936801 +0000 UTC m=+15849.700092341: ☑️ agreed by okJiang.

@ti-chi-bot ti-chi-bot bot merged commit 20087e2 into tikv:master Oct 28, 2024
25 checks passed
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. label Oct 30, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Oct 30, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.1: #8750.

lhy1024 added a commit to ti-chi-bot/pd that referenced this pull request Oct 30, 2024
ti-chi-bot bot pushed a commit that referenced this pull request Oct 31, 2024
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. label Dec 5, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Dec 5, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-7.5: #8871.

ti-chi-bot bot added a commit that referenced this pull request Dec 9, 2024
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>
@ti-chi-bot ti-chi-bot bot added the needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. label Dec 11, 2024
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this pull request Dec 11, 2024
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created to branch release-8.1: #8897.

ti-chi-bot bot added a commit that referenced this pull request Dec 12, 2024
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm needs-cherry-pick-release-7.1 Should cherry pick this PR to release-7.1 branch. needs-cherry-pick-release-7.5 Should cherry pick this PR to release-7.5 branch. needs-cherry-pick-release-8.1 Should cherry pick this PR to release-8.1 branch. release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Region may not be removed in hot peer cache after merging
4 participants