diff --git a/src/niceload b/src/niceload index 3bc9bea7..feeb07b3 100755 --- a/src/niceload +++ b/src/niceload @@ -455,10 +455,16 @@ sub over_run_limit { $status += (::max(1,$self->{'runmem'}/$mem)-1); } if($self->{'runload'}) { - # load should be between 0-10ish - # 0 load => 0 + # If used with other limits load should be between 0-10ish + no warnings 'numeric'; my $load = $self->load_status(); - $status += ::max(0,$load - $self->{'runload'}); + if($self->{'runload'} > 0) { + # Stop if the load is above the limit + $status += ::max(0,$load - $self->{'runload'}); + } else { + # Stop if the load is below the limit (for sensor) + $status += ::max(0,-$load - $self->{'runload'}); + } } if($self->{'runnoswap'}) { # swap should be between 0-10ish @@ -494,8 +500,15 @@ sub over_start_limit { if($self->{'startload'}) { # load should be between 0-10ish # 0 load => 0 + no warnings 'numeric'; my $load = $self->load_status(); - $status += ::max(0,$load - $self->{'startload'}); + if($self->{'startload'} > 0) { + # Stop if the load is above the limit + $status += ::max(0,$load - $self->{'startload'}); + } else { + # Stop if the load is below the limit (for sensor) + $status += ::max(0,-$load - $self->{'startload'}); + } } if($self->{'startnoswap'}) { # swap should be between 0-10ish diff --git a/src/parallel.texi b/src/parallel.texi index 9e32c87e..aa999ff9 100644 --- a/src/parallel.texi +++ b/src/parallel.texi @@ -452,6 +452,13 @@ Set the end of file string to eof-str. If the end of file string occurs as a line of input, the rest of the input is ignored. If neither @strong{-E} nor @strong{-e} is used, no end of file string is used. +@item @strong{--delay} @emph{secs} (alpha testing) +@anchor{@strong{--delay} @emph{secs} (alpha testing)} + +Delay starting next job @emph{secs} seconds. GNU @strong{parallel} will pause +@emph{secs} seconds after starting each job. @emph{secs} can be less than 1 +seconds. + @item @strong{--dry-run} @anchor{@strong{--dry-run}} diff --git a/testsuite/Makefile b/testsuite/Makefile index e2b5aefa..80199267 100644 --- a/testsuite/Makefile +++ b/testsuite/Makefile @@ -6,6 +6,9 @@ testdb: ../src/parallel tests-to-run/*sql* wanted-results/*sql* prereqdb time sh Start.sh sql date +local: testlocal + true + testlocal: ../src/parallel tests-to-run/*local* wanted-results/*local* prereqlocal time sh Start.sh local date diff --git a/testsuite/tests-to-run/niceload02.sh b/testsuite/tests-to-run/niceload02.sh index f333951d..311e17ec 100755 --- a/testsuite/tests-to-run/niceload02.sh +++ b/testsuite/tests-to-run/niceload02.sh @@ -4,7 +4,10 @@ echo '### Test niceload exit code' niceload "perl -e 'exit(3)'" ; echo $? eq 3 niceload "perl -e 'exit(0)'" ; echo $? eq 0 +# force load > 10 +while uptime | grep -v age:.[1-9][0-9].[0-9][0-9] >/dev/null ; do (timeout 5 nice burnP6 2>/dev/null &) done + echo '### Test -p' perl -e '$|=1;while($t++<3){sleep(1);print "."}' & # The above should be suspended for at least 4 seconds -stdout /usr/bin/time -f %e niceload -D -l -2 -p $! | perl -ne '$_ > 6 and print "OK\n"' +stdout /usr/bin/time -f %e niceload -D -l 9 -p $! | perl -ne '$_ > 6 and print "OK\n"' diff --git a/testsuite/tests-to-run/parallel-local164.sh b/testsuite/tests-to-run/parallel-local164.sh index 66865474..45702647 100644 --- a/testsuite/tests-to-run/parallel-local164.sh +++ b/testsuite/tests-to-run/parallel-local164.sh @@ -6,7 +6,8 @@ SERVER2=parallel-server2 # -L1 will join lines ending in ' ' cat <<'EOF' | sed -e s/\$SERVER1/$SERVER1/\;s/\$SERVER2/$SERVER2/ | parallel -j10 -k -L1 echo "### Test --delay" -seq 9 | /usr/bin/time -f %e parallel -j3 --delay 0.3 true {} 2>&1 | perl -pe 's/.[0-9]+$//' +seq 9 | /usr/bin/time -f %e parallel -j3 --delay 0.53 true {} 2>&1 | + perl -ne '$_ > 5 and print "More than 5 secs: OK\n"' echo '### Test -k 5'; sleep 5 diff --git a/testsuite/tests-to-run/parallel-local21.sh b/testsuite/tests-to-run/parallel-local21.sh index eef82bb0..42b7a2df 100644 --- a/testsuite/tests-to-run/parallel-local21.sh +++ b/testsuite/tests-to-run/parallel-local21.sh @@ -23,7 +23,7 @@ rm /tmp/basic--shebang-wrap echo "### Test --shebang-wrap with parser options" cat < /tmp/with-parser--shebang-wrap -#!/usr/local/bin/parallel --shebang-wrap /usr/bin/perl -p +#!/usr/local/bin/parallel --shebang-wrap -k /usr/bin/perl -p print "Shebang from perl with args @ARGV\n"; EOF @@ -31,11 +31,11 @@ EOF chmod 755 /tmp/with-parser--shebang-wrap /tmp/with-parser--shebang-wrap /tmp/in12 /tmp/in45 echo "### Same as" -parallel /usr/bin/perl -p /tmp/with-parser--shebang-wrap ::: /tmp/in12 /tmp/in45 +parallel -k /usr/bin/perl -p /tmp/with-parser--shebang-wrap ::: /tmp/in12 /tmp/in45 echo "### stdin" (echo /tmp/in12; echo /tmp/in45) | /tmp/with-parser--shebang-wrap echo "### Same as" -(echo /tmp/in12; echo /tmp/in45) | parallel /usr/bin/perl /tmp/with-parser--shebang-wrap +(echo /tmp/in12; echo /tmp/in45) | parallel -k /usr/bin/perl /tmp/with-parser--shebang-wrap rm /tmp/with-parser--shebang-wrap diff --git a/testsuite/wanted-results/parallel-local164 b/testsuite/wanted-results/parallel-local164 index f9fae32d..36627013 100644 --- a/testsuite/wanted-results/parallel-local164 +++ b/testsuite/wanted-results/parallel-local164 @@ -1,5 +1,5 @@ ### Test --delay -3 +More than 5 secs: OK ### Test -k 5 ### Test -k 3 ### Test -k 4