-
Notifications
You must be signed in to change notification settings - Fork 475
Prepare code for two-level scheduling #5469
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
Prepare code for two-level scheduling #5469
Conversation
✅ Deploy Preview for kubernetes-sigs-kueue canceled.
|
|
Hi @lchrzaszcz. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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-sigs/prow repository. |
9f737a5 to
f9af513
Compare
| bestFitIdx := 0 | ||
| for i, domain := range domains { | ||
| if domain.state >= count && domain.state != domains[bestFitIdx].state { | ||
| if domain.state >= count && domain.state < domains[bestFitIdx].state { |
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.
Previous code relied on a fact that domains are in descending order, so "!=" works perfectly in finding the tightest fit. I'm just changing it to "<" to make it more explicit.
pkg/cache/tas_flavor_snapshot.go
Outdated
| if a.state == b.state { | ||
| return slices.Compare(a.levelValues, b.levelValues) | ||
| } |
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'm not convinced I like the proposed abtraction - I would prefer avoid duplicating this.
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.
From the perspective of this PR it seems redundant, but looking at introduction or chunks, there'll be more custom logic to both modes.
What we could do is something like that:
if a.state == b.state {
return slices.Compare(a.levelValues, b.levelValues)
}
if useLeastFreeCapacityAlgorithm(unconstrained) {
// ascending order
return cmp.Compare(a.state, b.state)
} else {
// descending order
return cmp.Compare(b.state, a.state)
}What do you think?
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.
lgtm
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.
ok, I think the reason we are going to update this logic while working on two-level scheduling is motivation to avoid duplication, and thus diverging the code more in the future
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.
Got it, well I've just realized that with suggested solution I'm reinventing the wheel and the code look like that before. So I'm reverting my proposed change and I'll revert similar change in two-level scheduling PR.
| } | ||
| results = append(results, sortedDomain[idx+offset]) | ||
| remainingCount -= sortedDomain[idx].state | ||
| remainingCount -= sortedDomain[idx+offset].state |
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.
The code should subtract the chosen domain state from remainingCount. Old code subtracted not the chosen one, but next in line. It is the same for all domains, apart from the last one in BestFit. The old code worked ok, because remainingCount is a local variable, and we only care it is "not greater than 0" at the end of the function, so even if it was lower than 0 it was fine.
I'm fixing it to account for the optimized last domain correctly.
gabesaba
left a comment
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.
/lgtm
will leave approval for @mimowo
|
LGTM label has been added. Git tree hash: ffdf58608c9950c875679e783bfb37fd3c9f0c05
|
|
I would like to wait for #5469 (comment) |
f9af513 to
35f49cc
Compare
mimowo
left a comment
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.
/lgtm
/approve
Thanks 👍
|
LGTM label has been added. Git tree hash: 0d6e3978a71601639d29505149d1321cdefc15f2
|
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lchrzaszcz, mimowo 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 |
Done. I've reverted the code as it looked like that before my changes. |
|
/ok-to-test |
|
/unhold |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
This PRs introduces some preparation changes that do not change the logic of the code, but makes it easier to review https://github.com/kubernetes-sigs/kueue/pull/5353/files which is TAS two-level scheduling
Relates to: #5439
Preparation PR for: https://github.com/kubernetes-sigs/kueue/pull/5353/files
Which issue(s) this PR fixes:
Special notes for your reviewer:
Does this PR introduce a user-facing change?