From 5ef53dda9cb6bfdec34040bff85ec8eda4ccf59b Mon Sep 17 00:00:00 2001 From: Hubert Kario Date: Thu, 8 May 2014 03:13:45 +0200 Subject: [PATCH] increase paralelism of jobs because sometimes tcping takes a long time to timeout for a lot of hosts in batch use also load average to keep the cpu busy --- top1m/testtop1m.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/top1m/testtop1m.sh b/top1m/testtop1m.sh index 23a9775..19b450d 100755 --- a/top1m/testtop1m.sh +++ b/top1m/testtop1m.sh @@ -1,13 +1,23 @@ #!/usr/bin/env bash -parallel=50 +parallel=10 max_bg=50 +absolute_max_bg=100 +max_load=50 + +if [ $(ulimit -u) -lt $((10*absolute_max_bg)) ]; then + echo "max user processes too low, use ulimit -u to increase" + exit 1 +fi [ ! -e "results" ] && mkdir results function wait_for_jobs() { local no_jobs no_jobs=$(jobs | wc -l) - while [ $no_jobs -gt $1 ]; do + while [ $no_jobs -gt $1 ] || awk -v maxload=$max_load '{ if ($1 < maxload) exit 1 }' /proc/loadavg; do + if awk -v maxload=$max_load '{ if ($1 > maxload) exit 1 }' /proc/loadavg && [ $no_jobs -lt $absolute_max_bg ]; then + return + fi sleep 1 no_jobs=$(jobs | wc -l) done