-
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
scheduler: hot-scheduler supports rank formula v2 #5515
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. |
4c48287
to
b47cf99
Compare
99b2be2
to
e10fb14
Compare
Codecov ReportBase: 75.72% // Head: 75.72% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #5515 +/- ##
========================================
Coverage 75.72% 75.72%
========================================
Files 325 326 +1
Lines 32055 32250 +195
========================================
+ Hits 24274 24422 +148
- Misses 5700 5737 +37
- Partials 2081 2091 +10
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. |
76a48c7
to
d85ec40
Compare
ForbidRWType: "none", | ||
} | ||
cfg.apply(defaultConfig) | ||
cfg.applyPrioritiesConfig(defaultPrioritiesConfig) |
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.
Maybe we could add a new config for v2
, which set write leader priorities
to query,byte
.
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.
+1
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.
Introducing new config can be in a new PR.
@@ -2033,7 +1951,7 @@ func TestHotScheduleWithPriority(t *testing.T) { | |||
hb.(*hotScheduler).conf.StrictPickingStore = false | |||
ops, _ = hb.Schedule(tc, false) | |||
re.Len(ops, 1) | |||
testutil.CheckTransferPeer(re, ops[0], operator.OpHotRegion, 2, 5) // two dims will be better | |||
testutil.CheckTransferPeer(re, ops[0], operator.OpHotRegion, 1, 5) |
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.
Add comments about this changes.
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.
Here is the code that rolled back #4912
server/schedulers/hot_region_v2.go
Outdated
} | ||
|
||
rs := &rankV2Ratios{balancedRatio: balancedRatio, perceivedRatio: perceivedRatio, minHotRatio: minHotRatio} | ||
rs.preBalancedRatio = math.Max(2.0*balancedRatio-1.0, balancedRatio-0.15) |
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 use balancedRatio-0.15
directly :), it's hard to understand the purpose... (0.85 is the intersection)
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 original formula is 1.0 - 2 * (1.0 - balancedRatio)
. The maximum value with balancedRatio-0.1
is to prevent the preBalance range becoming too large.
/run-build-arm64 comment=true |
download pd binary(linux arm64) at http://fileserver.pingcap.net/download/builds/pingcap/test/pd/bee1fbe54095db62088cb3354e90f1196da6734f/centos7/pd-linux-arm64.tar.gz |
Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
Signed-off-by: HunDunDM <hundundm@gmail.com>
bee1fbe
to
8d0c563
Compare
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 for v1.
} | ||
|
||
if conf.RankFormulaVersion != "" && conf.RankFormulaVersion != "v1" && conf.RankFormulaVersion != "v2" { | ||
return errs.ErrSchedulerConfig.FastGenByArgs("invalid rank-formula-version") |
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.
return errs.ErrSchedulerConfig.FastGenByArgs("invalid rank-formula-version") | |
return errs.ErrSchedulerConfig.FastGenByArgs("invalid rank-formula-version, it should be v1 or v2") |
return err | ||
} else if pm[QueryPriority] { | ||
return errors.New("qps is not allowed to be set in priorities for write-peer-priorities") | ||
return errs.ErrSchedulerConfig.FastGenByArgs("qps is not allowed to be set in priorities for write-peer-priorities") |
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.
return errs.ErrSchedulerConfig.FastGenByArgs("qps is not allowed to be set in priorities for write-peer-priorities") | |
return errs.ErrSchedulerConfig.FastGenByArgs("query is not allowed to be set in priorities for write-peer-priorities") |
@@ -1022,14 +1031,22 @@ func (bs *balanceSolver) calcProgressiveRank() { | |||
|
|||
// isTolerance checks source store and target store by checking the difference value with pendingAmpFactor * pendingPeer. | |||
// This will make the hot region scheduling slow even serialize running when each 2 store's pending influence is close. | |||
func (bs *balanceSolver) isTolerance(dim int) bool { | |||
func (bs *balanceSolver) isTolerance(dim int, reverse bool) bool { |
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.
add comment for reverse
?
} | ||
firstCmp = rankCmp(bs.cur.getPeersRateFromCache(bs.firstPriority), old.getPeersRateFromCache(bs.firstPriority), stepRank(0, dimToStep(bs.firstPriority))) | ||
secondCmp = rankCmp(bs.cur.getPeersRateFromCache(bs.secondPriority), old.getPeersRateFromCache(bs.secondPriority), stepRank(0, dimToStep(bs.secondPriority))) | ||
var dimToStep = [statistics.DimLen]float64{ |
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.
Maybe we need a more reasonable step. Of course, it should be another issue.
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.
others lgtm
// minNotWorsenedRate == minBetterRate == minBalancedRate <= maxBalancedRate == maxBetterRate == maxNotWorsenedRate | ||
|
||
// highRate - (highRate+lowRate)/(1.0+balancedRatio) | ||
minNotWorsenedRate := (highRate*rs.balancedRatio - lowRate) / (1.0 + rs.balancedRatio) |
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.
Add comments about this formula. such as:
if (highRate - peerRate) > (lowRate + peerRate)
then balance state: (highRate - peerRate) * balancedRatio <= (lowRate + peerRate) => peerRate then (highRate*rs.balancedRatio - lowRate) / (1.0 + rs.balancedRatio)
if (highRate - peerRate) < (lowRate + peerRate)
then blance state : ..
// highRate - (highRate+lowRate)/(1.0+balancedRatio)*balancedRatio | ||
maxNotWorsenedRate := (highRate - lowRate*rs.balancedRatio) / (1.0 + rs.balancedRatio) | ||
|
||
if minNotWorsenedRate > 0 { |
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.
< 0?
/merge |
@HunDunDM: 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: 8d0c563
|
What problem does this PR solve?
Issue Number: Close #5021
What is changed and how does it work?
Need to merge #5501 first.
New score algorithm and
betterThan
algorithm.Check List
Tests
Code changes
Side effects
Related changes
Release note