X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/498d29adee40f671fd2924c410226db7a6a0ba93..355173ba2e8c42b29011493d1d8c7cc4d69295c6:/services/crunch-dispatch-slurm/priority.go diff --git a/services/crunch-dispatch-slurm/priority.go b/services/crunch-dispatch-slurm/priority.go index 8c27043051..2312ce5952 100644 --- a/services/crunch-dispatch-slurm/priority.go +++ b/services/crunch-dispatch-slurm/priority.go @@ -4,19 +4,27 @@ package main +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. +// +// 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) @@ -27,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