X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/da17cdccd11d66a10cbc3bf7fbd8c84b49d4a67c..98d6c8c5743e0fd6be85af3b9f30286a358bd1d4:/services/crunch-dispatch-slurm/priority.go?ds=sidebyside diff --git a/services/crunch-dispatch-slurm/priority.go b/services/crunch-dispatch-slurm/priority.go index 1445d2e70b..2312ce5952 100644 --- a/services/crunch-dispatch-slurm/priority.go +++ b/services/crunch-dispatch-slurm/priority.go @@ -4,27 +4,27 @@ package main -import "git.curoverse.com/arvados.git/sdk/go/arvados" - -type slurmJob struct { - ctr *arvados.Container - priority int64 // current slurm priority (incorporates nice value) - nice int64 // current slurm nice value -} +const defaultSpread int64 = 10 // wantNice calculates appropriate nice values for a set of SLURM // jobs. The returned slice will have len(jobs) elements. // -// spread is a non-negative amount of space to leave between adjacent +// spread is a positive amount of space to leave between adjacent // priorities when making adjustments. Generally, increasing spread // reduces the total number of adjustments made. A smaller spread // produces lower nice values, which is useful for old SLURM versions // with a limited "nice" range and for sites where SLURM is also // running non-Arvados jobs with low nice values. -func wantNice(jobs []slurmJob, spread int64) []int64 { +// +// If spread<1, a sensible default (10) is used. +func wantNice(jobs []*slurmJob, spread int64) []int64 { if len(jobs) == 0 { return nil } + + if spread < 1 { + spread = defaultSpread + } renice := make([]int64, len(jobs)) // highest usable priority (without going out of order) @@ -35,13 +35,13 @@ func wantNice(jobs []slurmJob, spread int64) []int64 { // priority container gets the highest // possible slurm priority. target = job.priority + job.nice - } else if space := target - job.priority; space >= 0 && space < spread*10 { + } else if space := target - job.priority; space >= 0 && space < (spread-1)*10 { // Ordering is correct, and interval isn't too // large. Leave existing nice value alone. renice[i] = job.nice target = job.priority } else { - target -= spread + target -= (spread - 1) if possible := job.priority + job.nice; target > possible { // renice[i] is already 0, that's the // best we can do