From e97dedeca850e65359b46ef7105432d4bcb5149b Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Tue, 6 Mar 2018 13:39:23 -0800 Subject: [PATCH] jobd.pl: change default number of parallel jobs The limiting factor tends not to be CPU when the number of CPU cores available increases, but rather the random access speed of the hard disk. Having a large number of parallel jobs can actually reduce performance due to hard-disk thrashing. Nevertheless, there is a period of just waiting for network activity while doing mirror updates that does not cause disk thrashing at all. Therefore scale back on the default number of parallel jobs as the number of detected CPU cores increases and cap the maximum default to no more than sixteen. Of course any explicitly set value will continue to be used, this change only affects the default if no value is specified explicitly. Signed-off-by: Kyle J. McKay --- jobd/jobd.pl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/jobd/jobd.pl b/jobd/jobd.pl index 7200d90..afbce57 100755 --- a/jobd/jobd.pl +++ b/jobd/jobd.pl @@ -20,12 +20,21 @@ use Girocco::Util; BEGIN {noFatalsToBrowser} use Girocco::ExecUtil; +sub _defjobs { + my $cpus = shift; + return 4 unless defined($cpus) && $cpus ne "" && int($cpus) >= 1; + return int($cpus * 2) if $cpus <= 2; + return 5 if $cpus < 4; + return int($cpus * 1.5) if $cpus <= 10; + return 16; +} + # Options my $quiet = 0; my $progress = 0; my $cpus = online_cpus; my $kill_after = 900; -my $max_par = $cpus ? $cpus * 2 : 8; +my $max_par = $cpus ? _defjobs($cpus) : 4; my $max_par_intensive = 1; my $load_triggers = $cpus ? sprintf("%g,%g", $cpus * 1.5, $cpus * 0.75) : "6,3"; my $lockfile = "/tmp/jobd-$Girocco::Config::tmpsuffix.lock"; @@ -669,7 +678,9 @@ Kill supervised jobs after a certain time to avoid hanging the daemon. =item B<--max-parallel NUM> Run no more than that many jobs at the same time. The default is the number -of cpus * 2. If the number of cpus cannot be determined, the default is 8. +of cpus * 2 for 1 or 2 cpus, 5 for 3 cpus and int(cpus * 1.5) for 4 cpus or +more with the default capped to 16 when more than 10 cpus are detected. +If the number of cpus cannot be determined, the default is 4. =item B<--max-intensive-parallel NUM> -- 2.11.4.GIT