You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@yunikorn.apache.org by "Hedger Lai (Jira)" <ji...@apache.org> on 2026/10/06 10:58:00 UTC
[jira] [Created] (YUNIKORN-3493) [Core] Eliminate redundant second pass and snapshot cloning in calculateVictimsByNode
Hedger Lai created YUNIKORN-3493:
------------------------------------
Summary: [Core] Eliminate redundant second pass and snapshot cloning in calculateVictimsByNode
Key: YUNIKORN-3493
URL: https://issues.apache.org/jira/browse/YUNIKORN-3493
Project: Apache YuniKorn
Issue Type: Improvement
Components: core - scheduler
Reporter: Hedger Lai
Assignee: Hedger Lai
h3. Problem
In {{Preemptor.calculateVictimsByNode()}}, victim selection currently runs two full passes over candidate allocations and calls {{p.duplicateQueueSnapshots()}} and {{nodeAvailable.Clone()}} twice per node:
1. In the first pass, {{head}} victims already have their allocations deducted from {{allocationsByQueueSnap}} and added to {{nodeCurrentAvailable}}, while {{tail}} victims have their queue deductions reverted.
2. Once {{nodeCurrentAvailable}} fits the ask in the first pass, the loop still computes {{SubEliminateNegative}} shortfall checks for every remaining candidate instead of directly moving the remaining slice to {{tail}}.
3. The function then resets {{nodeCurrentAvailable}} and clones {{allocationsByQueueSnap}} a second time just to re-verify {{head}} and {{tail}} from scratch.
h3. Proposed Improvement
1. Stop the first pass early once {{nodeCurrentAvailable.FitIn(p.ask.GetAllocatedResource())}} is satisfied, appending {{potentialVictims[i+1:]}} directly to {{tail}}.
2. Reuse the existing {{allocationsByQueueSnap}} from the first pass (which already reflects all {{head}} deductions) to validate and append eligible {{tail}} victims, eliminating the redundant second pass and duplicate snapshot cloning.
3. Extract {{tryRemoveVictimFromQueue}} helper to remove duplicated queue constraint checks and the {{//nolint:funlen}} directive.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@yunikorn.apache.org
For additional commands, e-mail: dev-help@yunikorn.apache.org