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

core: change score calculator in few disk space to avoid offline earlier #3592

Merged
merged 4 commits into from
Apr 16, 2021

Conversation

bufferflies
Copy link
Contributor

@bufferflies bufferflies commented Apr 14, 2021

What problem does this PR solve?

issue: #3589
when I use math to consider score similator in low space:
image
the score will be mostly affect by C, so their socres is different,the lower disk has few score than higher disk. so it will move region to lower store to run out of disk :
similator :
image
image

What is changed and how it works?

core regionScoreV2 calculator, store's score will increase rapidly when it disk space less than F.
the F param is not 20G, it should be set by the store's disk space , F will be set:

F=max(50,capacity*(1-lowSpaceRatio))

I want to the score should be similar when they has same free space in low disk space, so use linear calculator.
image

similator result:

image
test result:
image

it work well in low space

Check List

Tests

  • Integration test
  • Manual test (add detailed scripts or steps below)

Code changes

Side effects

Related changes

  • Need to cherry-pick to the release branch

Release note

  • modify score calculator to satisfy isomerous stores

Signed-off-by: tongjian <1045931706@qq.com>

Signed-off-by: tongjian <1045931706@qq.com>
@codecov
Copy link

codecov bot commented Apr 14, 2021

Codecov Report

Merging #3592 (be56b18) into master (9097e68) will increase coverage by 0.09%.
The diff coverage is 80.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3592      +/-   ##
==========================================
+ Coverage   74.56%   74.65%   +0.09%     
==========================================
  Files         245      245              
  Lines       24137    24139       +2     
==========================================
+ Hits        17997    18022      +25     
+ Misses       4521     4505      -16     
+ Partials     1619     1612       -7     
Flag Coverage Δ
unittests 74.65% <80.00%> (+0.09%) ⬆️

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

Impacted Files Coverage Δ
server/core/store.go 81.62% <80.00%> (+0.15%) ⬆️
server/kv/etcd_kv.go 79.71% <0.00%> (-5.80%) ⬇️
server/member/member.go 68.27% <0.00%> (-4.84%) ⬇️
server/election/leadership.go 83.52% <0.00%> (-2.36%) ⬇️
pkg/dashboard/adapter/manager.go 82.97% <0.00%> (-2.13%) ⬇️
server/schedulers/utils.go 93.10% <0.00%> (-1.38%) ⬇️
server/grpc_service.go 47.85% <0.00%> (+0.45%) ⬆️
server/server.go 72.14% <0.00%> (+0.45%) ⬆️
server/schedule/operator/step.go 69.10% <0.00%> (+1.66%) ⬆️
client/base_client.go 85.40% <0.00%> (+2.16%) ⬆️
... and 3 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 9097e68...be56b18. Read the comment docs.

@@ -319,7 +320,7 @@ func (s *StoreInfo) regionScoreV2(delta int64, deviation int) float64 {
score = (K + M*(math.Log(C)-math.Log(A-F+1))/(C-A+F-1)) * R
} else {
// When remaining space is less then F, the score is mainly determined by available space.
score = (K+M*math.Log(C)/C)*R + (F-A)*(K+M*math.Log(F)/F)
score = (K+M*math.Log(C)/C)*R + B*(F-A)*(K+M*math.Log(F)/F)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we make F configuration and set to a more suitable default value?

Copy link
Member

Choose a reason for hiding this comment

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

What is the relationship between F and low-space-ratio? BTW, I think it is a little bit confusing and misleading.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

low-space-ratio: avoid other region move in
F: it will increase score after it's free disk less than F, so it will move out region to other
I agree the two args misleading

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use max(20,capacity*(1-lowSpaceRatio)) to set F, so it will eliminate F and low-space-ratio meaning

…the low space store can move regoin to others

Signed-off-by: tongjian <1045931706@qq.com>
Signed-off-by: tongjian <1045931706@qq.com>
@nolouch nolouch changed the title [core]:change score calculator in few disk space to avoid offline earlier core: change score calculator in few disk space to avoid offline earlier Apr 16, 2021
@nolouch nolouch added the needs-cherry-pick-release-5.0 The PR needs to cherry pick to release-5.0 branch. label Apr 16, 2021
Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 16, 2021
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • HunDunDM
  • nolouch

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 Apr 16, 2021
@sonarcloud
Copy link

sonarcloud bot commented Apr 16, 2021

Kudos, SonarCloud Quality Gate passed!

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

No Coverage information No Coverage information
0.0% 0.0% Duplication

@nolouch
Copy link
Contributor

nolouch commented Apr 16, 2021

/merge

@ti-chi-bot
Copy link
Member

@nolouch: 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: be56b18

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 16, 2021
@nolouch
Copy link
Contributor

nolouch commented Apr 16, 2021

/run-integration-ddl-test

@nolouch
Copy link
Contributor

nolouch commented Apr 16, 2021

/run-integration-compatibility-test

@nolouch
Copy link
Contributor

nolouch commented Apr 16, 2021

/run-integration-common-test

@nolouch
Copy link
Contributor

nolouch commented Apr 16, 2021

/merge

@ti-chi-bot
Copy link
Member

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

@nolouch nolouch merged commit 9d9c8ee into tikv:master Apr 16, 2021
ti-srebot pushed a commit to ti-srebot/pd that referenced this pull request Apr 16, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-5.0 in PR #3605

zhouqiang-cl pushed a commit that referenced this pull request Apr 16, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@bufferflies bufferflies deleted the feature/scoreV3 branch July 6, 2021 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-cherry-pick-release-5.0 The PR needs to cherry pick to release-5.0 branch. 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.

6 participants