Skip to content

Commit

Permalink
mxqd: Enforce minimum job runtime of 30 seconds
Browse files Browse the repository at this point in the history
Throttle througput for junk jobs. We don't want to busy
spin in the daemon and hammer the database if user
submits several jobs which immediately die or finish.
  • Loading branch information
donald committed Jul 6, 2017
1 parent 844fd6c commit 37bc8b1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,13 @@ int reaper_process(struct mxq_server *server,struct mxq_group_list *glist, struc
}
gettimeofday(&now, NULL);
timersub(&now, &job->stats_starttime, &realtime);

if (realtime.tv_sec<30) {
int wait=30-realtime.tv_sec;
mx_log_warning("user process finished to fast (%ld seconds) : delaying termination for %d seconds",realtime.tv_sec,wait);
sleep(wait);
}

res = getrusage(RUSAGE_CHILDREN, &rusage);
if (res < 0) {
mx_log_err("reaper: getrusage: %m");
Expand Down

0 comments on commit 37bc8b1

Please sign in to comment.