-
Notifications
You must be signed in to change notification settings - Fork 727
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: reduce unnecessary cpu time #5800
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Signed-off-by: lhy1024 <[email protected]>
Codecov ReportBase: 75.58% // Head: 75.57% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #5800 +/- ##
==========================================
- Coverage 75.58% 75.57% -0.01%
==========================================
Files 338 338
Lines 33592 33603 +11
==========================================
+ Hits 25390 25396 +6
- Misses 6018 6028 +10
+ Partials 2184 2179 -5
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Signed-off-by: lhy1024 <[email protected]>
Signed-off-by: lhy1024 <[email protected]>
if item != nil { | ||
item.actionType = Remove | ||
items = append(items, item) | ||
if ids, ok := f.storesOfRegion[regionID]; ok { |
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.
length of f.storesOfRegion
is less or equal than f.getAllStoreIDs
} | ||
return t.rates | ||
} | ||
|
||
// gets the storeIDs, including old region and new region | ||
func (f *hotPeerCache) getAllStoreIDs(region *core.RegionInfo) []uint64 { | ||
storeIDs := make(map[uint64]struct{}) |
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.
the length of peers is enough small, map consume unnecessary
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
ptal @rleungx |
zap.String("action-type", stat.actionType.String()), | ||
zap.Time("last-transfer-leader-time", stat.lastTransferLeaderTime)) | ||
func (stat *HotPeerStat) Log(str string) { | ||
if log.GetLevel() <= zap.DebugLevel { |
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 not just use log.Debug
?
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.
it will cost unnecessary cpu for zap
@@ -706,6 +703,40 @@ func TestHotPeerCacheTopN(t *testing.T) { | |||
re.Equal(3200.0, cache.calcHotThresholds(1)[KeyDim]) | |||
} | |||
|
|||
func TestHotPeerCacheTopNLen(t *testing.T) { |
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.
This test is almost the same as TestHotPeerCacheTopNThreshold
Signed-off-by: lhy1024 <[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.
The rest LGTM.
Signed-off-by: lhy1024 <[email protected]>
Signed-off-by: lhy1024 <[email protected]>
/merge |
@lhy1024: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: 966495e
|
Signed-off-by: lhy1024 [email protected]
What problem does this PR solve?
Issue Number: Close #5691
What is changed and how does it work?
Gauge.WithLabelValues
collectExpiredItems
andisOldColdPeer
andjustTransferLeader
Check List
Tests
reduce 16% (from 110s to 92s)
Before:
After:
Release note