From 33383bafc16eb7619bd94a0733480e1bbe6ef9e5 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sun, 20 Mar 2022 00:03:11 +0100 Subject: [PATCH] mxqd: Go into WAITING less frequently Only advertise WAITING state if there are jobs which could be started on this server. --- mxqd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mxqd.c b/mxqd.c index 5eedcd1..e3da795 100644 --- a/mxqd.c +++ b/mxqd.c @@ -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; @@ -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;