Skip to content

Commit

Permalink
revert infra change
Browse files Browse the repository at this point in the history
  • Loading branch information
d80tb7 committed Dec 2, 2024
1 parent aa6da1f commit 4728f78
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions internal/scheduler/jobdb/comparison.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,30 +113,23 @@ func MarketSchedulingOrderCompare(job, other *Job) int {
return 1
}

// PriorityClassPriority indicates urgency.
// Hence, jobs of higher priorityClassPriority come first.
if job.priorityClass.Priority > other.priorityClass.Priority {
// Next put a job with an active run ahead of queued jobs
jobIsActive := job.activeRun != nil && !job.activeRun.InTerminalState()
otherIsActive := other.activeRun != nil && !other.activeRun.InTerminalState()
if jobIsActive && !otherIsActive {
return -1
} else if job.priorityClass.Priority < other.priorityClass.Priority {
return 1
}

// Jobs higher in queue-priority come first.
if job.priority < other.priority {
return -1
} else if job.priority > other.priority {
if !jobIsActive && otherIsActive {
return 1
}

// If both jobs are active, order by time since the job was scheduled.
// This ensures jobs that have been running for longer are rescheduled first,
// which reduces wasted compute time when preempting.
jobIsActive := job.activeRun != nil && !job.activeRun.InTerminalState()
otherIsActive := other.activeRun != nil && !other.activeRun.InTerminalState()
if jobIsActive && otherIsActive {
if job.activeRunTimestamp < other.activeRunTimestamp {
if job.activeRunTimestamp > other.activeRunTimestamp {
return -1
} else if job.activeRunTimestamp > other.activeRunTimestamp {
} else if job.activeRunTimestamp < other.activeRunTimestamp {
return 1
}
}
Expand Down

0 comments on commit 4728f78

Please sign in to comment.