Skip to content

Commit

Permalink
mxqd: Go into WAITING less frequently
Browse files Browse the repository at this point in the history
Only advertise WAITING state if there are jobs which could be started
on this server.
  • Loading branch information
donald committed Mar 20, 2022
1 parent 1a33ee8 commit 33383ba
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,14 @@ static int can_start_job(struct mxq_group_list *group, unsigned long df_scratch,
return 1;
}

static int can_start_job_for_user(struct mxq_user_list *user, unsigned long df_scratch, struct mxq_server *server, long slots_to_start) {
/* Can we start a(nother) job for this user? */
for (struct mxq_group_list *group = user->groups; group; group = group->next)
if (can_start_job(group, df_scratch, server, slots_to_start))
return 1;
return 0;
}

unsigned long start_user(struct mxq_user_list *ulist, long slots_to_start, unsigned long df_scratch)
{
struct mxq_server *server;
Expand Down Expand Up @@ -1510,7 +1518,7 @@ long start_user_with_least_running_global_slot_count(struct mxq_server *server)
for (ulist = server->users; ulist; ulist = ulist->next) {
/* if a previous users is waiting for free resources, don't start jobs
* for later users. */
if (waiting)
if (waiting && can_start_job_for_user(ulist, df_scratch, server, slots_free))
/* returning -1 here tells the daemon to set its status in the
* database to WAITING, which is just informational. */
return -1;
Expand Down

0 comments on commit 33383ba

Please sign in to comment.