From 86ff25232c16fa8dce96d029a6ba0f9da56e8ec6 Mon Sep 17 00:00:00 2001 From: robertdavidsmith <34475852+robertdavidsmith@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:51:36 +0100 Subject: [PATCH] Scheduler: when evicting don't normalise actualShare (#3899) Signed-off-by: robersmi606 Co-authored-by: Robert Smith --- internal/scheduler/context/scheduling.go | 9 --------- internal/scheduler/preempting_queue_scheduler.go | 3 +-- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/internal/scheduler/context/scheduling.go b/internal/scheduler/context/scheduling.go index 40be0d7aaa8..c0f267393a6 100644 --- a/internal/scheduler/context/scheduling.go +++ b/internal/scheduler/context/scheduling.go @@ -144,15 +144,6 @@ func (sctx *SchedulingContext) GetQueue(queue string) (fairness.Queue, bool) { return qctx, ok } -// TotalCost returns the sum of the costs across all queues. -func (sctx *SchedulingContext) TotalCost() float64 { - var rv float64 - for _, qctx := range sctx.QueueSchedulingContexts { - rv += sctx.FairnessCostProvider.UnweightedCostFromQueue(qctx) - } - return rv -} - // UpdateFairShares updates FairShare and AdjustedFairShare for every QueueSchedulingContext associated with the // SchedulingContext. This works by calculating a far share as queue_weight/sum_of_all_queue_weights and an // AdjustedFairShare by resharing any unused capacity (as determined by a queue's demand) diff --git a/internal/scheduler/preempting_queue_scheduler.go b/internal/scheduler/preempting_queue_scheduler.go index de36595c395..8b4fed9225e 100644 --- a/internal/scheduler/preempting_queue_scheduler.go +++ b/internal/scheduler/preempting_queue_scheduler.go @@ -109,7 +109,6 @@ func (sch *PreemptingQueueScheduler) Schedule(ctx *armadacontext.Context) (*sche snapshot := sch.nodeDb.Txn(false) // Evict preemptible jobs. - totalCost := sch.schedulingContext.TotalCost() ctx.WithField("stage", "scheduling-algo").Infof("Evicting preemptible jobs") evictorResult, inMemoryJobRepo, err := sch.evict( armadacontext.WithLogField(ctx, "stage", "evict for resource balancing"), @@ -130,7 +129,7 @@ func (sch *PreemptingQueueScheduler) Schedule(ctx *armadacontext.Context) (*sche return false } if qctx, ok := sch.schedulingContext.QueueSchedulingContexts[job.Queue()]; ok { - actualShare := sch.schedulingContext.FairnessCostProvider.UnweightedCostFromQueue(qctx) / totalCost + actualShare := sch.schedulingContext.FairnessCostProvider.UnweightedCostFromQueue(qctx) fairShare := math.Max(qctx.AdjustedFairShare, qctx.FairShare) fractionOfFairShare := actualShare / fairShare if fractionOfFairShare <= sch.protectedFractionOfFairShare {