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: support hotPeerCache maintained in Peer level #3627

Merged
merged 21 commits into from
May 8, 2021

Conversation

Yisaer
Copy link
Contributor

@Yisaer Yisaer commented Apr 22, 2021

Signed-off-by: yisaer disxiaofei@163.com

What problem does this PR solve?

What is changed and how it works?

make hotPeerCache maintained by peer level

Release note

  • No release note

Signed-off-by: yisaer <disxiaofei@163.com>
@ti-chi-bot ti-chi-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 22, 2021
@codecov
Copy link

codecov bot commented Apr 22, 2021

Codecov Report

Merging #3627 (c4d33ca) into master (78d2dc4) will increase coverage by 0.01%.
The diff coverage is 89.19%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3627      +/-   ##
==========================================
+ Coverage   74.62%   74.63%   +0.01%     
==========================================
  Files         245      245              
  Lines       24144    24240      +96     
==========================================
+ Hits        18017    18092      +75     
- Misses       4512     4528      +16     
- Partials     1615     1620       +5     
Flag Coverage Δ
unittests 74.63% <89.19%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
server/core/kind.go 61.90% <ø> (ø)
server/statistics/kind.go 0.00% <0.00%> (ø)
server/cluster/coordinator.go 72.31% <46.66%> (-1.98%) ⬇️
server/api/trend.go 66.19% <50.00%> (ø)
server/tso/tso.go 70.11% <80.00%> (+0.17%) ⬆️
server/statistics/flowkind.go 83.33% <83.33%> (ø)
server/schedulers/hot_region.go 80.98% <86.86%> (+<0.01%) ⬆️
server/core/peer.go 83.33% <91.66%> (+4.16%) ⬆️
server/statistics/hot_peer_cache.go 94.46% <99.11%> (+1.28%) ⬆️
pkg/mock/mockcluster/mockcluster.go 94.41% <100.00%> (ø)
... and 24 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 78d2dc4...c4d33ca. Read the comment docs.

@Yisaer Yisaer marked this pull request as ready for review April 23, 2021 09:27
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 23, 2021
server/statistics/hot_peer_cache.go Outdated Show resolved Hide resolved
@@ -450,3 +437,70 @@ func (f *hotPeerCache) updateHotPeerStat(newItem, oldItem *HotPeerStat, bytes, k
}
return newItem
}

// TODO: remove it in future
func (f *hotPeerCache) getRegionBytes(region *core.RegionInfo) uint64 {
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems to be related with #3591

Signed-off-by: yisaer <disxiaofei@163.com>
@Yisaer Yisaer force-pushed the make_schedule_peer branch 2 times, most recently from 701d043 to 6e91990 Compare April 27, 2021 10:52
Signed-off-by: yisaer <disxiaofei@163.com>
@Yisaer
Copy link
Contributor Author

Yisaer commented Apr 27, 2021

/run-tests

@Yisaer
Copy link
Contributor Author

Yisaer commented Apr 27, 2021

/run-test

@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 29, 2021
Signed-off-by: yisaer <disxiaofei@163.com>
Signed-off-by: yisaer <disxiaofei@163.com>
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 30, 2021
Signed-off-by: yisaer <disxiaofei@163.com>
@Yisaer Yisaer requested a review from lhy1024 April 30, 2021 07:25
server/statistics/hot_peer_cache.go Outdated Show resolved Hide resolved
server/statistics/hot_peer_cache.go Outdated Show resolved Hide resolved
server/core/peer.go Outdated Show resolved Hide resolved
Signed-off-by: yisaer <disxiaofei@163.com>
server/core/peer.go Outdated Show resolved Hide resolved
Signed-off-by: yisaer <disxiaofei@163.com>
Yisaer added 4 commits May 7, 2021 17:19
Signed-off-by: yisaer <disxiaofei@163.com>
Signed-off-by: yisaer <disxiaofei@163.com>
Signed-off-by: yisaer <disxiaofei@163.com>
Signed-off-by: yisaer <disxiaofei@163.com>
isExpired := f.isPeerExpired(peer, region)
oldItem := f.getOldHotPeerStat(region.GetID(), storeID)
if isExpired && oldItem != nil && !f.isInheritExist(region.GetID()) {
f.putInheritItem(oldItem)
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 cause race?

// transfer read leader or remove write peer
isExpired := f.isPeerExpired(peer, region)
oldItem := f.getOldHotPeerStat(region.GetID(), storeID)
if isExpired && oldItem != nil && !f.isInheritExist(region.GetID()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why need to judge whether exist in inherit items?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed


func (f *hotPeerCache) isInheritExist(regionID uint64) bool {
item, ok := f.inheritItem[regionID]
return ok && item != nil
Copy link
Contributor

Choose a reason for hiding this comment

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

when is it nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

when there is no inherit item.

Yisaer added 2 commits May 8, 2021 12:09
Signed-off-by: yisaer <disxiaofei@163.com>
Signed-off-by: yisaer <disxiaofei@163.com>
Signed-off-by: yisaer <disxiaofei@163.com>
for {
select {
case <-ctx.Done():
close(w.readFlowQueue)
Copy link
Member

Choose a reason for hiding this comment

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

It's better to close it on send side.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated.

Signed-off-by: yisaer <disxiaofei@163.com>
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 8, 2021
server/cluster/cluster.go Outdated Show resolved Hide resolved
Signed-off-by: yisaer <disxiaofei@163.com>
@sonarcloud
Copy link

sonarcloud bot commented May 8, 2021

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 8 Code Smells

No Coverage information No Coverage information
1.7% 1.7% Duplication

@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lhy1024
  • rleungx

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels May 8, 2021
@Yisaer
Copy link
Contributor Author

Yisaer commented May 8, 2021

/merge

@ti-chi-bot
Copy link
Member

@Yisaer: 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.

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: c4d33ca

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label May 8, 2021
@Yisaer
Copy link
Contributor Author

Yisaer commented May 8, 2021

/run-integration-ddl-test

@ti-chi-bot ti-chi-bot merged commit df1614b into tikv:master May 8, 2021
@Yisaer Yisaer deleted the make_schedule_peer branch May 8, 2021 10:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants