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/schedule/placement/fit: pick out the candidates for a rule should be faster when cache the match result for peers to rules #5276

Open
AndreMouche opened this issue Jul 6, 2022 · 0 comments · May be fixed by #5277
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@AndreMouche
Copy link
Member

AndreMouche commented Jul 6, 2022

Enhancement Task

The function fitRule(idx) are try to find the best fit recursively, and the following part is to pick out the candidates for the current rule, which may repeatedly call the func MatchLabelConstraints when there are lots of rules. so, how about cache the result that if the peer(store, since 1 store can only have 1 peer, so we could use the peer directly) can match the rule

if checkRule(w.rules[index], w.stores) {
// Only consider stores:
// 1. Match label constraints
// 2. Role match, or can match after transformed.
// 3. Not selected by other rules.
for _, p := range w.peers {
if MatchLabelConstraints(p.store, w.rules[index].LabelConstraints) &&
!p.selected {
candidates = append(candidates, p)
}
}
}

@AndreMouche AndreMouche added the type/enhancement The issue or PR belongs to an enhancement. label Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant