Skip to content

Commit

Permalink
Scheduler: when evicting don't normalise actualShare (#3899)
Browse files Browse the repository at this point in the history
Signed-off-by: robersmi606 <[email protected]>
Co-authored-by: Robert Smith <[email protected]>
  • Loading branch information
robertdavidsmith and robdsmith authored Sep 4, 2024
1 parent e0cfd5b commit 86ff252
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
9 changes: 0 additions & 9 deletions internal/scheduler/context/scheduling.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions internal/scheduler/preempting_queue_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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 {
Expand Down

0 comments on commit 86ff252

Please sign in to comment.