Skip to content

Commit

Permalink
mxqd: Simplify start_user
Browse files Browse the repository at this point in the history
Historically, start_user was called with differenct values for the
job_limit argument. Jobs were started round-robin from the groups with
highest priority round-robin. If no more jobs could be started from that
priority, jobs from lower priority were considered, too.

The groups are ordered by priority.

Currently, start_user is always called with a job_limit argument of 1
and just the first eligible jobs is started.

Remove the job_limit argument and start a single job only.  Remove the
code complexity which is no longer needed.
  • Loading branch information
donald committed Jan 29, 2020
1 parent 5cabb59 commit babc019
Showing 1 changed file with 13 additions and 44 deletions.
57 changes: 13 additions & 44 deletions mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1273,18 +1273,12 @@ unsigned long start_job(struct mxq_group_list *glist)

/**********************************************************************/

unsigned long start_user(struct mxq_user_list *ulist, int job_limit, long slots_to_start)
unsigned long start_user(struct mxq_user_list *ulist, long slots_to_start)
{
struct mxq_server *server;
struct mxq_group_list *glist;
struct mxq_group_list *gnext = NULL;
struct mxq_group *group;

unsigned int prio;
unsigned char started = 0;
unsigned long slots_started = 0;
int jobs_started = 0;

unsigned long df_scratch;

assert(ulist);
Expand All @@ -1295,67 +1289,42 @@ unsigned long start_user(struct mxq_user_list *ulist, int job_limit, long slots_
glist = ulist->groups;
group = &glist->group;

prio = group->group_priority;

assert(slots_to_start <= server->slots - server->slots_running);

mx_log_debug(" user=%s(%d) slots_to_start=%ld job_limit=%d :: trying to start jobs for user.",
group->user_name, group->user_uid, slots_to_start, job_limit);
mx_log_debug(" user=%s(%d) slots_to_start=%ld :: trying to start jobs for user.",
group->user_name, group->user_uid, slots_to_start);

df_scratch=mx_df(MXQ_JOB_TMPDIR_FS "/.");

for (glist = ulist->groups; glist && slots_to_start > 0 && (!job_limit || jobs_started < job_limit); glist = gnext) {
for (glist = ulist->groups; glist ; glist = glist->next) {

group = &glist->group;
gnext = glist->next;

assert(glist->jobs_running <= group->group_jobs);
assert(glist->jobs_running <= glist->jobs_max);

if (glist->jobs_running == group->group_jobs) {
goto start_user_continue;
continue;
}
if (glist->jobs_running == glist->jobs_max) {
goto start_user_continue;
continue;
}
if (mxq_group_jobs_inq(group) == 0) {
goto start_user_continue;
continue;
}
if (glist->slots_per_job > slots_to_start) {
goto start_user_continue;
continue;
}

if (df_scratch/1024/1024/1024 < group->job_tmpdir_size + 20) {
goto start_user_continue;
continue;
}

if (group->group_priority < prio) {
if (started) {
goto start_user_rewind;
}
prio = group->group_priority;
}
mx_log_info(" group=%s(%d):%lu slots_to_start=%ld slots_per_job=%lu :: trying to start job for group.",
group->user_name, group->user_uid, group->group_id, slots_to_start, glist->slots_per_job);

if (start_job(glist)) {
slots_to_start -= glist->slots_per_job;
jobs_started++;
slots_started += glist->slots_per_job;

started = 1;
int slots_started = glist->slots_per_job;
return slots_started;
}

start_user_continue:
if (gnext || !started)
continue;

start_user_rewind:
gnext = ulist->groups;
started = 0;
continue;
}
return slots_started;
return 0;
}

/**********************************************************************/
Expand Down Expand Up @@ -1390,7 +1359,7 @@ long start_user_with_least_running_global_slot_count(struct mxq_server *server)
if (waiting && ulist->global_slots_running > global_slots_per_user)
return -1;

slots_started = start_user(ulist, 1, slots_free);
slots_started = start_user(ulist, slots_free);
if (slots_started)
return slots_started;

Expand Down

0 comments on commit babc019

Please sign in to comment.