-
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
filter: replace region.Clone in filter #2794
Conversation
Signed-off-by: Song Gao <disxiaofei@163.com>
ce40df2
to
6bfe1bf
Compare
Signed-off-by: Song Gao <disxiaofei@163.com>
6bfe1bf
to
4b9b632
Compare
server/schedule/filter/filters.go
Outdated
|
||
// cloneRegion is used to replace region.Clone in filter which call the FitRegion, | ||
// as FitRegion only needs partial information(startKey, endKey, peers, leader peer) | ||
func cloneRegion(region *core.RegionInfo, opts ...core.RegionCreateOption) *core.RegionInfo { |
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.
Do not clone the downPeers
, pendingPeers
? maybe rename to a suitable name?
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 createRegionForRuleFit(peers []*metapb.Peer, leader *metapb.Peer) *core.RegionInfo
?
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.
Signed-off-by: Song Gao <disxiaofei@163.com>
StoreId: leader.StoreId, | ||
Role: leader.Role, | ||
} | ||
copyPeers := make([]*metapb.Peer, 0, len(peers)) |
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.
Seems we don't have to copy leader. And if the peer list is untouched, we don't need to copy it either.
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.
I think for both ruleFitFilter
and ruleLeaderFitFilter
, they will both touch peers and leaders. I think it is necessary to copy peers and leaders either.
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 makes sense.
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.
BTW, How about the benchmark result?
I updated the benchmark result in the description. |
/merge |
/run-all-tests |
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
cherry pick to release-4.0 in PR #2801 |
Signed-off-by: Song Gao <disxiaofei@163.com>
Signed-off-by: Song Gao <disxiaofei@163.com> Signed-off-by: ZenoTan <zenotan1998@gmail.com>
Signed-off-by: Song Gao <disxiaofei@163.com>
Signed-off-by: Song Gao <disxiaofei@163.com>
Signed-off-by: Song Gao disxiaofei@163.com
What problem does this PR solve?
ref #2783
region.Clone consumes too much cpu resources.
What is changed and how it works?
replace region.Clone with a self-maintained clone function as FitRegion only need partial information of a region.
BenchmarkCloneRegionTest is using new clone method and BenchmarkCloneRegionTest2 is using region.Clone
$ go test -bench=. -run=none goos: darwin goarch: amd64 pkg: github.com/tikv/pd/server/schedule/filter BenchmarkCloneRegionTest-4 4356267 267 ns/op BenchmarkCloneRegionTest2-4 316604 3292 ns/op PASS ok github.com/tikv/pd/server/schedule/filter 2.555s
Check List
Tests
Related changes
Release note