This is an automated email from the ASF dual-hosted git repository.

wilfred-s pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 7dc1287c [YUNIKORN-3351] Hoist the per-ask backoff getter out of 
tryAllocate (#1121)
7dc1287c is described below

commit 7dc1287c839f5ddcc5d0b1cd14e6f4614a6e09e0
Author: Tigerquoll <[email protected]>
AuthorDate: Mon Aug 10 19:39:05 2026 +1000

    [YUNIKORN-3351] Hoist the per-ask backoff getter out of tryAllocate (#1121)
    
    tryAllocate re-fetched sa.queue.GetMaxAppUnschedAskBackoff() once per ask 
walked,
    although the value is constant for the whole scheduling cycle. The getter 
takes
    the queue lock on every call, so an application with a long ask list pays a 
queue
    lock acquisition per ask for a value that cannot change while tryAllocate 
holds
    the application lock.
    
    Generated by Author with assistance from Claude Code.
    
    Signed-off-by: Tigerquoll <[email protected]>
    
    Closes: #1121
    
    Signed-off-by: Wilfred Spiegelenburg <[email protected]>
---
 pkg/scheduler/objects/application.go | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/pkg/scheduler/objects/application.go 
b/pkg/scheduler/objects/application.go
index 3d4d8130..2d6ced96 100644
--- a/pkg/scheduler/objects/application.go
+++ b/pkg/scheduler/objects/application.go
@@ -1084,15 +1084,17 @@ func (sa *Application) canReplace(request *Allocation) 
bool {
 func (sa *Application) tryAllocate(headRoom *resources.Resource, 
allowPreemption bool, preemptionDelay time.Duration, preemptAttemptsRemaining 
*int, nodeIterator func() NodeIterator, fullNodeIterator func() NodeIterator, 
getNodeFn func(string) *Node) *AllocationResult {
        sa.Lock()
        defer sa.Unlock()
-       if sa.sortedRequests == nil {
+       if len(sa.sortedRequests) == 0 {
                return nil
        }
        // calculate the users' headroom, includes group check which requires 
the applicationID
        userHeadroom := ugm.GetUserManager().Headroom(sa.queuePath, 
sa.ApplicationID, sa.user)
        unschedulable := uint64(0)
+       // constant for the cycle: hoisted out of the loop below. Safe to call 
unconditionally here
+       // because the len check above guarantees at least one iteration would 
occur.
+       backoffThreshold := sa.queue.GetMaxAppUnschedAskBackoff()
        // get all the requests from the app sorted in order
        for _, request := range sa.sortedRequests {
-               backoffThreshold := sa.queue.GetMaxAppUnschedAskBackoff()
                if backoffThreshold > 0 && unschedulable >= backoffThreshold {
                        log.Log(log.SchedApplication).Info("too many 
unschedulable asks in the application, waiting",
                                zap.String("application ID", sa.ApplicationID),


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to