2010-10-14 21:13:48 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-01-24 01:02:07 +00:00
|
|
|
# SPDX-FileCopyrightText: 2021-2024 Ole Tange, http://ole.tange.dk and Free Software and Foundation, Inc.
|
2021-03-22 20:16:35 +00:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-07-24 07:13:30 +00:00
|
|
|
cpuburn=$(mktemp)
|
2023-02-03 15:37:25 +00:00
|
|
|
qcpuburn=$(parallel -0 --shellquote ::: "$cpuburn")
|
2017-06-22 11:35:58 +00:00
|
|
|
(echo '#!/usr/bin/perl'
|
2023-01-30 21:51:56 +00:00
|
|
|
echo "eval{setpriority(0,0,9)}; while(1){}") > "$cpuburn"
|
|
|
|
chmod 700 "$cpuburn"
|
|
|
|
basename=$(basename "$cpuburn")
|
2017-06-22 11:35:58 +00:00
|
|
|
|
2014-08-22 21:30:39 +00:00
|
|
|
forceload () {
|
|
|
|
# Force load
|
|
|
|
LOAD=$1
|
2017-06-22 11:35:58 +00:00
|
|
|
# Start 10 times as many cpuburn
|
2023-02-03 15:37:25 +00:00
|
|
|
seq 0 0.1 $1 | parallel -j0 timeout 20 "$qcpuburn" 2>/dev/null &
|
2013-11-22 17:24:09 +00:00
|
|
|
PID=$!
|
2014-08-22 21:30:39 +00:00
|
|
|
# Give GNU Parallel 1 second to startup
|
|
|
|
sleep 1
|
|
|
|
perl -e 'do{$a=`uptime`} while($a=~/average: *(\S+)/ and $1 < '$LOAD')'
|
2017-06-22 11:35:58 +00:00
|
|
|
# Load is now > $LOAD
|
2013-03-06 23:16:53 +00:00
|
|
|
}
|
|
|
|
|
2014-08-22 21:30:39 +00:00
|
|
|
# Force load avg > number of cpu cores
|
|
|
|
forceload $(parallel --number-of-cores)
|
2013-03-06 23:16:53 +00:00
|
|
|
|
2018-09-20 22:15:14 +00:00
|
|
|
cat <<'EOF' | sed -e 's/;$/; /;s/$SERVER1/'$SERVER1'/;s/$SERVER2/'$SERVER2'/' | stdout parallel -vj0 -k --joblog /tmp/jl-`basename $0` -L1 -r
|
2013-03-06 23:16:53 +00:00
|
|
|
echo "bug #38441: CPU usage goes to 100% if load is higher than --load at first job"
|
|
|
|
/usr/bin/time -f %e parallel --load 100% true ::: a 2>&1 |
|
|
|
|
perl -ne '$_ > 1 and print "More than 1 secs wall clock: OK\n"'
|
|
|
|
|
|
|
|
/usr/bin/time -f %U parallel --load 100% true ::: a 2>&1 |
|
|
|
|
perl -ne '$_ < 1 and print "Less than 1 secs user time: OK\n"'
|
|
|
|
|
2011-03-20 21:40:12 +00:00
|
|
|
echo '### Test slow arguments generation - https://savannah.gnu.org/bugs/?32834'
|
2013-03-06 23:16:53 +00:00
|
|
|
seq 1 3 | parallel -j1 "sleep 2; echo {}" | parallel -kj2 echo
|
2014-08-22 21:30:39 +00:00
|
|
|
EOF
|
|
|
|
|
2017-06-22 11:35:58 +00:00
|
|
|
# Make sure we got all the cpuburn killed
|
2023-01-30 21:51:56 +00:00
|
|
|
killall "$basename" 2>/dev/null
|
2011-03-20 21:40:12 +00:00
|
|
|
|
2013-12-19 01:19:19 +00:00
|
|
|
echo '### Test too slow spawning'
|
2013-03-06 23:16:53 +00:00
|
|
|
# Let the commands below run during high load
|
2023-02-03 15:37:25 +00:00
|
|
|
seq 1000 | timeout 20 parallel -j400% -N0 "$qcpuburn" 2>/dev/null &
|
2014-08-22 21:30:39 +00:00
|
|
|
PID=$!
|
|
|
|
seq 1 1000 | stdout nice nice parallel --halt 1 -uj0 -N0 kill $PID |
|
2023-01-30 21:51:56 +00:00
|
|
|
perl -pe '/parallel: Warning: Starting \d+ processes took/ and do {close STDIN; `kill '$PID';killall "$basename"`; print "OK\n"; exit }';
|
2013-03-06 23:16:53 +00:00
|
|
|
|
2017-06-22 11:35:58 +00:00
|
|
|
# Make sure we got all the cpuburn killed
|
2023-01-30 21:51:56 +00:00
|
|
|
killall "$basename" 2>/dev/null
|
|
|
|
rm "$cpuburn"
|