-
Notifications
You must be signed in to change notification settings - Fork 711
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
server: update balance score to [0,100]. #159
Conversation
// 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 |
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 we should use int for (0, 100), not float64 now.
Btw, (0, 100) means we can't get 0 or 100?
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.
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 |
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.
you may always get 0 here.
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.
So the comment [0,100] is much better?
LGTM |
@shenli PTAL |
if regionCount == 0 { | ||
return 0 | ||
} | ||
|
||
return float64(s.stats.leaderRegionCount) / float64(regionCount) | ||
return s.stats.leaderRegionCount / regionCount |
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.
Multiple 100.
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.
Yep, missed it.
LGTM |
No description provided.