enhancement(victim selection): improve same job-priority victim selection#5113
enhancement(victim selection): improve same job-priority victim selection#5113hajnalmt wants to merge 3 commits intovolcano-sh:masterfrom
Conversation
…rder Apply plugin job CompareFn first in BuildVictimsPriorityQueue and use TaskOrderFn as the tie-breaker when job ordering is equal, including preemptor-missing paths, so creation timestamp does not dominate same-priority victim selection. Signed-off-by: Hajnal Máté <hajnalmt@gmail.com>
Add BuildVictimsPriorityQueue unit coverage for job-order ties falling back to task-order, including preemptor-found and preemptor-missing paths. Place the test in package framework_test so it can use real plugin wiring without creating an import cycle between framework and plugin packages. Signed-off-by: Hajnal Máté <hajnalmt@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the victim selection mechanism within the scheduler's Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request effectively improves victim selection for jobs with the same priority by introducing a more robust tie-breaking mechanism. The refactoring of JobOrderFn into JobOrderCompareFn is a clean approach that enhances code reuse. The new logic in BuildVictimsPriorityQueue correctly uses TaskOrderFn as a tie-breaker, avoiding reliance on creation timestamps. The addition of a dedicated unit test is also a valuable contribution. I have one minor suggestion to improve comment clarity.
There was a problem hiding this comment.
Pull request overview
Improves victim selection ordering when multiple victims belong to jobs with the same job priority by using plugin job ordering first and TaskOrderFn as a deterministic tie-breaker (instead of implicitly falling back to timestamp/UID behavior).
Changes:
- Introduce
JobOrderCompareFnto expose plugin-only job ordering comparison results. - Update
BuildVictimsPriorityQueueto apply job ordering first and task ordering when job ordering ties (including the “preemptor job missing” path). - Add focused unit tests for the updated victim ordering behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| pkg/scheduler/framework/session_plugins.go | Adds plugin-only job compare and uses task-order as tie-break in victim PQ ordering. |
| pkg/scheduler/framework/session_plugins_victim_order_test.go | Adds unit tests asserting the victim ordering outcome in both preemptor-job-present/missing paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Set deterministic PodGroup creation timestamps and assert JobOrderCompareFn tie conditions so task-order fallback behavior is validated consistently. Update BuildVictimsPriorityQueue comments to match current ordering paths, including orphaned jobs and queue-based handling. Signed-off-by: Hajnal Máté <hajnalmt@gmail.com>
What type of PR is this?
/kind rfe
/kind feature
What this PR does / why we need it:
This PR improves same job-priority victim selection in
BuildVictimsPriorityQueueby applying plugin job compare first and usingTaskOrderFnas tie-break when job ordering is equal.The behavior is applied in both the preemptor-missing path and the same-queue path so creation timestamp is not the implicit final decision maker.
Which issue(s) this PR fixes:
Fixes #5112
Special notes for your reviewer:
pkg/scheduler/framework/session_plugins.go.pkg/scheduler/framework/session_plugins_victim_order_test.go.framework_testpackage to avoid import cycle with real plugin wiring.return lv.CreationTimestamp.Before(&rv.CreationTimestamp)meansreturn truewhenlvis older thanrv, so if two jobs have the same priority the order is asceding by timestamp, for thejobOrderresulting in oldest first job ordering. For the victims we have negated this via!ssn.JobOrderFn(...)resulting in youngest first victim selection, so we evicted younger jobs on the cluster instead of the older jobs in the reclaim and preempt actions.In volcano’s queue where victims flow,
when job ranks tie, task rules shall show;
no timestamp shall decide the fight,
task-order keeps the choice set right.
Does this PR introduce a user-facing change?