Skip to content

KEP-5598: Extend opportunistic batching with rescoring#6039

Open
romanbaron wants to merge 3 commits intokubernetes:masterfrom
romanbaron:opportunistic-batching-rescore
Open

KEP-5598: Extend opportunistic batching with rescoring#6039
romanbaron wants to merge 3 commits intokubernetes:masterfrom
romanbaron:opportunistic-batching-rescore

Conversation

@romanbaron
Copy link
Copy Markdown
Contributor

  • One-line PR description:
    Add rescoring to handle multi-pod-per-node workloads: when the last chosen node remains feasible, rescore it in-place and continue batching rather than flushing the cache.
  • Other comments:
    AI tooling was used to assist in preparing this PR. All changes have been reviewed and verified by the author.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 29, 2026
@k8s-ci-robot k8s-ci-robot requested a review from dom4ha April 29, 2026 08:45
@k8s-ci-robot k8s-ci-robot added the kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory label Apr 29, 2026
@k8s-ci-robot k8s-ci-robot requested a review from macsko April 29, 2026 08:45
@k8s-ci-robot k8s-ci-robot added the sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. label Apr 29, 2026
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 29, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in SIG Scheduling Apr 29, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @romanbaron. Thanks for your PR.

I'm waiting for a kubernetes 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.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

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.

Details

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 the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 29, 2026
Copy link
Copy Markdown

@singh1203 singh1203 left a comment

Choose a reason for hiding this comment

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

Hey @romanbaron, thanks for including me. I went through the full diff carefully. Overall, the rescoring design is clean and well written. I just had one question, and thanks for answering it. 🙇
Overall, it looks good to me.

Comment thread keps/sig-scheduling/5598-opportunistic-batching/README.md
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: romanbaron, singh1203
Once this PR has been reviewed and has the lgtm label, please assign macsko for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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

Comment thread keps/sig-scheduling/5598-opportunistic-batching/kep.yaml Outdated
Comment thread keps/sig-scheduling/5598-opportunistic-batching/kep.yaml Outdated
Comment thread keps/sig-scheduling/5598-opportunistic-batching/README.md Outdated
Comment thread keps/sig-scheduling/5598-opportunistic-batching/README.md
Comment thread keps/sig-scheduling/5598-opportunistic-batching/README.md Outdated
@romanbaron romanbaron force-pushed the opportunistic-batching-rescore branch from afbce01 to 38281e1 Compare May 4, 2026 08:23
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 4, 2026
@romanbaron romanbaron force-pushed the opportunistic-batching-rescore branch from eda4b71 to 5734340 Compare May 4, 2026 13:59
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 4, 2026
@romanbaron romanbaron force-pushed the opportunistic-batching-rescore branch 2 times, most recently from e9c449d to 703870e Compare May 4, 2026 16:17
@romanbaron romanbaron force-pushed the opportunistic-batching-rescore branch from 703870e to 8119e15 Compare May 4, 2026 16:43
@romanbaron
Copy link
Copy Markdown
Contributor Author

The PR is now rebased on top of the refactored KEP and only includes Rescore-related changes.

@macsko
Copy link
Copy Markdown
Member

macsko commented May 5, 2026

/ok-to-test

@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. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 5, 2026
Comment thread keps/sig-scheduling/5598-opportunistic-batching/README.md
Comment on lines +403 to +404
2. `Score` is called for each scoring plugin against node A using the current `CycleState`. The
resulting score accurately reflects pod N's placement.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe that node states can change over time. For example, I think the following cases could occur:

  • Changes in ImageLocality scores due to image GC
  • Taints are being added to a node
  • Pods terminating

It is possible that these events occur on nodes other than Node A, causing their scores to change. Ideally, scoring should be performed on all nodes, but doing so would negate the benefits of this change.
Is this acceptable?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I agree with your observation, and I think this can affect not only scoring but also filtering. A taint applied to a node might make that node infeasible for the next pod. That said, this concern also applies to the current design, since cached nodes do not go through filtering on every cycle.

Cache staleness is bounded by maxBatchAge (500ms). This is explained in more detail in the risks and mitigations section here.

In theory, the scheduler snapshot could also have been taken before such a taint was applied, so the same issue can occur without Opportunistic Batching as well, although the risk is probably much lower.

I think this is important to document this concern, but I don’t see how it can be eliminated without removing the Opportunistic Batching optimization entirely.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Still, the scheduler is only eventually consistent and it can observe any cluster change with some delay. Moreover, kube-scheduler doesn't pick the fully optimal score, because it subsample number of feasible nodes to score. Given than and the small age of batching information, this proposal is fine.

Copy link
Copy Markdown
Member

@utam0k utam0k May 6, 2026

Choose a reason for hiding this comment

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

I posted my comment because I felt this was a potential concern. If the decision has been made to accept the risks, then I think this policy is fine. Thank you.

Comment thread keps/sig-scheduling/5598-opportunistic-batching/README.md Outdated
@romanbaron romanbaron force-pushed the opportunistic-batching-rescore branch from 7d19290 to f4cd3a0 Compare May 6, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory ok-to-test Indicates a non-member PR verified by an org member that is safe to test. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

Status: Needs Triage

Development

Successfully merging this pull request may close these issues.

5 participants