X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=fast_make.sh;h=bd57b858e4e5e90bb8c41d5f95405145a5b7c4ed;hb=ab861698aadb27e5a4d11291df30cff97f03d23d;hp=471562c515aa0da35d00b7f21ff2298046409d57;hpb=931a42358442f4ee4f314613c991c838d4b4e3b7;p=clitk.git diff --git a/fast_make.sh b/fast_make.sh index 471562c..bd57b85 100755 --- a/fast_make.sh +++ b/fast_make.sh @@ -1,8 +1,9 @@ #!/bin/bash vv_dir=$(dirname $(readlink -e $(which $0))) -echo vv directory: $vv_dir +echo clitk3 directory: $vv_dir cd ${vv_dir}/build + function handle_exit { rm mem_use 2>>/dev/null @@ -26,44 +27,47 @@ then sleep 1 make -j${cpus} else #use all the available computing power by default - cpus=$(( $(cat /proc/cpuinfo | grep -c ^processor) + 0 )) + cpus=$(( $(cat /proc/cpuinfo | grep -c ^processor) + 2 )) + echo "Building with ${cpus} cpus..." fi -make -j ${cpus} $@ & -make_pid=$(jobs -p %make) +nice -n12 ionice -c3 make -j ${cpus} $@ & +make_pid=$(jobs -p %nice) + #watch memory use to avoid crashes -while ps $make_pid >>/dev/null -do - if [ x"$(ps aux | grep cc1plus | grep -v grep | wc -l)" != x0 ] - then - ps ax -o vsize,comm | grep cc1plus | grep -o "\<[0-9]*\>" > mem_use - used_mem=$(awk 'BEGIN {sum=0;} {sum+=$1;} END {print sum;}' mem_use) - if (( "$used_mem"> ($available_mem - 300) )) - then - touch memory_exhausted_lock - echo "Stopping due to exagerated memory use ( $used_mem )" - handle_exit - elif (( "$used_mem"> ($available_mem/2) )) - then - if [ x$high_mem != xtrue ] - then - echo "Warning, high memory use, not spawning any more compilation jobs... ( $used_mem )" - killall -s SIGSTOP make - killall -s SIGCONT cc1plus - high_mem="true" - date_mem=$(date +%s) - fi - echo mem $used_mem / $available_mem - elif [ x$high_mem = xtrue ] && (( $(date +%s) > ( $date_mem + 5 ) )) - then - echo "Memory use back to normal" - high_mem="" - killall -s SIGCONT make - fi - rm mem_use - fi - sleep 1 -done -rm memory_exhausted_lock 2>>/dev/null +#while ps $make_pid >>/dev/null +#do +# if [ x"$(ps aux | grep cc1plus | grep -v grep | wc -l)" != x0 ] +# then +# ps ax -o vsize,comm | grep cc1plus | grep -o "\<[0-9]*\>" > mem_use +# used_mem=$(awk 'BEGIN {sum=0;} {sum+=$1;} END {print sum;}' mem_use) +# if (( "$used_mem"> ($available_mem - 300) )) +# then +# touch memory_exhausted_lock +# echo "Stopping due to exagerated memory use ( $used_mem )" +# handle_exit +# elif (( "$used_mem"> ($available_mem/2) )) +# then +# if [ x$high_mem != xtrue ] +# then +# echo "Warning, high memory use, not spawning any more compilation jobs... ( $used_mem )" +# killall -s SIGSTOP make +# killall -s SIGCONT cc1plus +# high_mem="true" +# date_mem=$(date +%s) +# fi +# echo mem $used_mem / $available_mem +# elif [ x$high_mem = xtrue ] && (( $(date +%s) > ( $date_mem + 5 ) )) +# then +# echo "Memory use back to normal" +# high_mem="" +# killall -s SIGCONT make +# fi +# rm mem_use +# fi +# sleep 1 +#done +#rm memory_exhausted_lock 2>>/dev/null +wait echo Done! echo