Skip to content

Commit 2eb4936

Browse files
committed
Update dispatchQuery to use min_cores
Sorting jobs only by priority causes a situation where low priority jobs can get starved by a constant flow of high priority jobs. The new formula adds a modifier to the sorting rank to take into account the number of cores the job is requesting and also the number of days the job is waiting on the queue. Priorities numbers over 200 will mostly override the formula and work as a priority only based scheduling. sort = priority + (100 * (1 - (job.cores/job.int_min_cores))) + (age in days) Besides that, also take layer_int_cores_min into account when filtering folder_resourse limitations to avoid allocating more cores than the folder limits. (cherry picked from commit 566411aeeddc60983a30eabe121fd03263d05525)
1 parent 953273c commit 2eb4936

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

cuebot/src/main/java/com/imageworks/spcue/dao/postgres/DispatchQuery.java

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
/*
3-
* Copyright Contributors to the OpenCue Project
3+
* Copyright (c) 2018 Sony Pictures Imageworks Inc.
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
66
* you may not use this file except in compliance with the License.
@@ -23,11 +23,23 @@ public class DispatchQuery {
2323

2424
public static final String FIND_JOBS_BY_SHOW =
2525
"/* FIND_JOBS_BY_SHOW */ " +
26-
"SELECT pk_job, int_priority, rank FROM ( " +
26+
"SELECT pk_job, int_priority, rank FROM ( " +
2727
"SELECT " +
28-
"ROW_NUMBER() OVER (ORDER BY job_resource.int_priority DESC) AS rank, " +
29-
"job.pk_job, " +
30-
"job_resource.int_priority " +
28+
"ROW_NUMBER() OVER (ORDER BY int_priority DESC) AS rank, " +
29+
"pk_job, " +
30+
"int_priority " +
31+
"FROM ( " +
32+
"SELECT " +
33+
"job.pk_job as pk_job, " +
34+
"/* sort = priority + (100 * (1 - (job.cores/job.int_min_cores))) + (age in days) */ " +
35+
"CAST( " +
36+
"job_resource.int_priority + ( " +
37+
"100 * (CASE WHEN job_resource.int_min_cores <= 0 THEN 0 " +
38+
"ELSE 1 - job_resource.int_cores/job_resource.int_min_cores " +
39+
"END) " +
40+
") + ( " +
41+
"(DATE_PART('days', NOW()) - DATE_PART('days', job.ts_updated)) " +
42+
") as INT) as int_priority " +
3143
"FROM " +
3244
"job , " +
3345
"job_resource , " +
@@ -50,7 +62,7 @@ public class DispatchQuery {
5062
"(" +
5163
"folder_resource.int_max_cores = -1 " +
5264
"OR " +
53-
"folder_resource.int_cores < folder_resource.int_max_cores " +
65+
"folder_resource.int_cores + layer.int_cores_min < folder_resource.int_max_cores " +
5466
") " +
5567
"AND job.str_state = 'PENDING' " +
5668
"AND job.b_paused = false " +
@@ -91,7 +103,7 @@ public class DispatchQuery {
91103
"sum_running.int_sum_running < limit_record.int_max_value " +
92104
"OR sum_running.int_sum_running IS NULL " +
93105
") " +
94-
") AS t1 WHERE rank < ?";
106+
") AS t1 ) AS t2 WHERE rank < ?";
95107

96108

97109
public static final String FIND_JOBS_BY_GROUP =

0 commit comments

Comments
 (0)