]> Creatis software - clitk.git/blob - fast_make.sh
almost finished the work on multiple components
[clitk.git] / fast_make.sh
1 #!/bin/bash
2 vv_dir=$(dirname $(readlink -e $(which $0)))
3 echo clitk3 directory: $vv_dir
4 cd ${vv_dir}/build
5
6 nice -n 19 ionice -c3 make -j4 #is this good enough?
7
8 #
9 #function handle_exit
10 #{
11 #    rm mem_use 2>>/dev/null
12 #    killall -s SIGCONT make
13 #    killall make
14 #    killall cc1plus
15 #    echo "Terminated, exiting..."
16 #    echo
17 #    echo
18 #    exit
19 #}
20 #
21 #trap handle_exit SIGINT
22 #available_mem=$(cat /proc/meminfo | grep MemTotal | grep -o [0-9]*)
23 #if [ -a "memory_exhausted_lock" ]
24 #then
25 #   echo "Running in memory conservation mode..."
26 #   max_cpp_process_mem_use=1600000
27 #   cpus=$(( $available_mem / $max_cpp_process_mem_use ))
28 #   echo "Using $cpus cpu(s) should be safe..."
29 #   sleep 1
30 #   make -j${cpus}
31 #else #use all the available computing power by default
32 #    cpus=$(( $(cat /proc/cpuinfo | grep -c ^processor) + 0 ))
33 #fi
34 #
35 #nice -n12 ionice -c3 make -j ${cpus} $@ &
36 #make_pid=$(jobs -p %nice)
37 #
38 ##watch memory use to avoid crashes
39 #while ps $make_pid >>/dev/null 
40 #do
41 #    if [ x"$(ps aux | grep cc1plus | grep -v grep | wc -l)" != x0 ]
42 #    then
43 #        ps ax -o vsize,comm | grep cc1plus | grep -o "\<[0-9]*\>" > mem_use
44 #        used_mem=$(awk 'BEGIN {sum=0;} {sum+=$1;} END {print sum;}' mem_use)
45 #        if (( "$used_mem"> ($available_mem - 300) ))
46 #        then
47 #            touch memory_exhausted_lock
48 #            echo "Stopping due to exagerated memory use ( $used_mem )"
49 #            handle_exit
50 #        elif (( "$used_mem"> ($available_mem/2) ))
51 #        then
52 #            if [ x$high_mem != xtrue ]
53 #            then
54 #                echo "Warning, high memory use, not spawning any more compilation jobs... ( $used_mem )"
55 #                killall -s SIGSTOP make
56 #                killall -s SIGCONT cc1plus
57 #                high_mem="true"
58 #                date_mem=$(date +%s)
59 #            fi
60 #            echo mem $used_mem / $available_mem
61 #        elif [ x$high_mem = xtrue ] && (( $(date +%s) > ( $date_mem + 5 ) ))
62 #        then
63 #            echo "Memory use back to normal"
64 #            high_mem=""
65 #            killall -s SIGCONT make
66 #        fi
67 #        rm mem_use
68 #    fi
69 #    sleep 1
70 #done
71 #rm memory_exhausted_lock 2>>/dev/null
72 #echo Done!
73 #echo