Skip to content

Conversation

@lchrzaszcz
Copy link
Contributor

@lchrzaszcz lchrzaszcz commented Jun 3, 2025

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?

NONE

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 3, 2025
@netlify
Copy link

netlify bot commented Jun 3, 2025

Deploy Preview for kubernetes-sigs-kueue canceled.

Name Link
🔨 Latest commit 35f49cc
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-kueue/deploys/683ee76ae05031000861ec54

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 3, 2025
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 3, 2025
@k8s-ci-robot
Copy link
Contributor

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 3, 2025
@lchrzaszcz lchrzaszcz force-pushed the two-level-tas-scheduling-preparation branch from 9f737a5 to f9af513 Compare June 3, 2025 11:40
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 3, 2025
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 {
Copy link
Contributor Author

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.

Comment on lines 823 to 825
if a.state == b.state {
return slices.Compare(a.levelValues, b.levelValues)
}
Copy link
Contributor

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.

Copy link
Contributor Author

@lchrzaszcz lchrzaszcz Jun 3, 2025

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor Author

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.

@lchrzaszcz lchrzaszcz marked this pull request as ready for review June 3, 2025 11:58
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 3, 2025
@k8s-ci-robot k8s-ci-robot requested a review from PBundyra June 3, 2025 11:59
Copy link
Contributor

@gabesaba gabesaba left a 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

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 3, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: ffdf58608c9950c875679e783bfb37fd3c9f0c05

@mimowo
Copy link
Contributor

mimowo commented Jun 3, 2025

I would like to wait for #5469 (comment)

@lchrzaszcz lchrzaszcz force-pushed the two-level-tas-scheduling-preparation branch from f9af513 to 35f49cc Compare June 3, 2025 12:15
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 3, 2025
@k8s-ci-robot k8s-ci-robot requested a review from gabesaba June 3, 2025 12:15
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 3, 2025
Copy link
Contributor

@mimowo mimowo left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
Thanks 👍

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 3, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 0d6e3978a71601639d29505149d1321cdefc15f2

@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 3, 2025
@lchrzaszcz
Copy link
Contributor Author

I would like to wait for #5469 (comment)

Done. I've reverted the code as it looked like that before my changes.

@mimowo
Copy link
Contributor

mimowo commented Jun 3, 2025

/ok-to-test
/hold
to make sure tests pass, feel free to unhold

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 3, 2025
@lchrzaszcz
Copy link
Contributor Author

/unhold

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 3, 2025
@k8s-ci-robot k8s-ci-robot merged commit 310626e into kubernetes-sigs:main Jun 3, 2025
23 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v0.13 milestone Jun 3, 2025
@lchrzaszcz lchrzaszcz deleted the two-level-tas-scheduling-preparation branch June 3, 2025 13:08
ichekrygin pushed a commit to ichekrygin/kueue that referenced this pull request Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants