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

scheduler: introduce the rank interface #8353

Merged
merged 6 commits into from
Jul 25, 2024

Conversation

rleungx
Copy link
Member

@rleungx rleungx commented Jul 2, 2024

What problem does this PR solve?

Issue Number: Ref #5691

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-linked-issue dco-signoff: yes Indicates the PR's author has signed the dco. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 2, 2024
@@ -0,0 +1,243 @@
// Copyright 2017 TiKV Project Authors.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Copyright 2017 TiKV Project Authors.
// Copyright 2024 TiKV Project Authors.

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jul 2, 2024
@rleungx rleungx requested a review from nolouch July 3, 2024 02:27
@rleungx
Copy link
Member Author

rleungx commented Jul 3, 2024

/test ?

Copy link
Contributor

ti-chi-bot bot commented Jul 3, 2024

@rleungx: The following commands are available to trigger required jobs:

  • /test build

The following commands are available to trigger optional jobs:

  • /test pull-integration-copr-test
  • /test pull-integration-realcluster-test

Use /test all to run the following jobs that were automatically triggered:

  • tikv/pd/ghpr_build
  • tikv/pd/pull_integration_realcluster_test

In response to this:

/test ?

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 kubernetes/test-infra repository.

@rleungx
Copy link
Member Author

rleungx commented Jul 3, 2024

/test pull-integration-realcluster-test

@okJiang
Copy link
Member

okJiang commented Jul 3, 2024

What problem does this PR solve?🤔

Copy link

codecov bot commented Jul 9, 2024

Codecov Report

Attention: Patch coverage is 84.91379% with 35 lines in your changes missing coverage. Please review.

Project coverage is 77.36%. Comparing base (624b6f3) to head (aae0f36).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8353      +/-   ##
==========================================
+ Coverage   77.34%   77.36%   +0.01%     
==========================================
  Files         471      472       +1     
  Lines       61914    61903      -11     
==========================================
  Hits        47890    47890              
+ Misses      10448    10434      -14     
- Partials     3576     3579       +3     
Flag Coverage Δ
unittests 77.36% <84.91%> (+0.01%) ⬆️

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

Comment on lines +215 to 187
// for metrics
for storeID, info := range storeInfos {
storeLabel := strconv.FormatUint(storeID, 10)
if infl := info.PendingSum; infl != nil && len(infl.Loads) != 0 {
utils.ForeachRegionStats(func(rwTy utils.RWType, dim int, kind utils.RegionStatKind) {
setHotPendingInfluenceMetrics(storeLabel, rwTy.String(), utils.DimToString(dim), infl.Loads[kind])
HotPendingSum.WithLabelValues(storeLabel, rwTy.String(), utils.DimToString(dim)).Set(infl.Loads[kind])
})
}
}
}

Copy link
Member

Choose a reason for hiding this comment

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

It is better to wrap a function for these codes

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's unnecessary.

@@ -533,19 +535,8 @@ type balanceSolver struct {
maxPeerNum int
minHotDegree int

firstPriorityV2Ratios *rankV2Ratios
secondPriorityV2Ratios *rankV2Ratios

// The rank correlation function used according to the version
Copy link
Member

Choose a reason for hiding this comment

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

Is this note still needed?

default:
bs.initRankV2()
bs.rank = initRankV2(bs, bs.greatDecRatio)
Copy link
Member

Choose a reason for hiding this comment

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

Why not input bs only?

rankToDimString func() string
checkByPriorityAndTolerance func(loads []float64, f func(int) bool) bool
checkHistoryLoadsByPriority func(loads [][]float64, f func(int) bool) bool
rank rank
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 this?

Suggested change
rank rank
rank

}

func (*rankV1) needSearchRevertRegions() bool { return false }
func (*rankV1) setSearchRevertRegions() {}
Copy link
Member

Choose a reason for hiding this comment

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

🤔

Suggested change
func (*rankV1) setSearchRevertRegions() {}
func (*rankV1) setSearchRevertRegions() {}

@@ -59,7 +51,7 @@ type balanceChecker struct {
// If the ratio is between the two, it is considered to be in the pre-balanced state.

// TODO: Unified with stddevThreshold.
type rankV2Ratios struct {
type rankRatios struct {
Copy link
Member

Choose a reason for hiding this comment

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

please update all rankV2Ratios to rankRatios

}

// pickCheckPolicyV2 will set checkByPriorityAndTolerance to the corresponding function.
// Note: PolicyV2 will search more possible solutions than PolicyV1.
// so it allows to schedule when any of the two dimensions is not balanced.
func (bs *balanceSolver) pickCheckPolicyV2() {
func (r *rankV2) checkHistoryLoadsByPriority(loads [][]float64, f func(int) bool) bool {
Copy link
Member

Choose a reason for hiding this comment

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

please update comment

}
}

// filterUniformStoreV2 filters stores by stddev.
// stddev is the standard deviation of the store's load for all stores.
func (bs *balanceSolver) filterUniformStoreV2() (string, bool) {
if !bs.enableExpectation() {
func (r *rankV2) filterUniformStore() (string, bool) {
Copy link
Member

Choose a reason for hiding this comment

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

ditto

bs.cur.calcPeersRate(bs.firstPriority, bs.secondPriority)
if bs.cur.getPeersRateFromCache(bs.firstPriority) < bs.getMinRate(bs.firstPriority) &&
bs.cur.getPeersRateFromCache(bs.secondPriority) < bs.getMinRate(bs.secondPriority) {
func (r *rankV2) calcProgressiveRank() {
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor

ti-chi-bot bot commented Jul 19, 2024

@okJiang: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

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 kubernetes/test-infra repository.

Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
Signed-off-by: Ryan Leung <rleungx@gmail.com>
futureChecker: futureStateChecker,
currentChecker: currentStateChecker,
perceivedRatio: perceivedRatio, minHotRatio: minHotRatio}

return rs
}

func (bs *balanceSolver) initRankV2() {
bs.firstPriorityV2Ratios = newRankV2Ratios(bs.sche.conf.GetGreatDecRatio(), firstPriorityPerceivedRatio, firstPriorityMinHotRatio)
// The second priority is less demanding. Set the preBalancedRatio of the first priority to the balancedRatio of the second dimension.
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to keep this comment?

Signed-off-by: Ryan Leung <rleungx@gmail.com>
Copy link
Contributor

ti-chi-bot bot commented Jul 25, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: HuSharp, lhy1024, okJiang

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 added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jul 25, 2024
Copy link
Contributor

ti-chi-bot bot commented Jul 25, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-07-02 10:20:45.879557509 +0000 UTC m=+1319772.365046341: ☑️ agreed by lhy1024.
  • 2024-07-25 02:42:06.449384542 +0000 UTC m=+1099348.440326012: ☑️ agreed by HuSharp.

@ti-chi-bot ti-chi-bot bot merged commit 1f14057 into tikv:master Jul 25, 2024
21 checks passed
@rleungx rleungx deleted the introduce-rank-interface branch July 25, 2024 03:56
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 release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants