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

server: update balance score to [0,100]. #159

Merged
merged 5 commits into from
Jun 20, 2016

Conversation

qiuyesuifeng
Copy link
Contributor

No description provided.

// TODO: we should adjust the weight of used ratio and leader score in futher,
// now it is a little naive.
func (cb *capacityBalancer) score(store *storeInfo, regionCount int) float64 {
usedRatioScore := store.usedRatio()
leaderScore := store.leaderScore(regionCount)
score := usedRatioScore*0.6 + leaderScore*0.4
score := (usedRatioScore*0.6 + leaderScore*0.4) * 100
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use int for (0, 100), not float64 now.
Btw, (0, 100) means we can't get 0 or 100?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually we may get 0 score, but it is invalid i think.
float64 can be int in our algorithm.

usedRatioScore := store.usedRatio()
leaderScore := store.leaderScore(regionCount)
score := (usedRatioScore*0.6 + leaderScore*0.4) * 100
score := int(usedRatioScore*0.6+leaderScore*0.4) * 100
Copy link
Contributor

Choose a reason for hiding this comment

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

you may always get 0 here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the comment [0,100] is much better?

@siddontang
Copy link
Contributor

LGTM

@qiuyesuifeng
Copy link
Contributor Author

@shenli PTAL

if regionCount == 0 {
return 0
}

return float64(s.stats.leaderRegionCount) / float64(regionCount)
return s.stats.leaderRegionCount / regionCount
Copy link
Member

Choose a reason for hiding this comment

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

Multiple 100.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, missed it.

@qiuyesuifeng qiuyesuifeng changed the title server: update balance score to (0,100). server: update balance score to [0,100]. Jun 20, 2016
@shenli
Copy link
Member

shenli commented Jun 20, 2016

LGTM

@qiuyesuifeng qiuyesuifeng merged commit 061b583 into qiuyesuifeng/new-balance Jun 20, 2016
@qiuyesuifeng qiuyesuifeng deleted the qiuyesuifeng/adjust-score branch June 20, 2016 01:52
rleungx pushed a commit to rleungx/pd that referenced this pull request Dec 1, 2023
close tikv#6875

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants