diff -Naur distcc-2.18.3/bench/Build.py distcc-2.18.3.new/bench/Build.py --- distcc-2.18.3/bench/Build.py 2004-10-23 22:05:32.000000000 -0700 +++ distcc-2.18.3.new/bench/Build.py 2006-01-03 18:04:18.000000000 -0800 @@ -95,6 +95,7 @@ rm_files((build_log, distcc_log)) + sys.stdout.flush() print "** Building..." if self.project.pre_build_cmd: cmd = ("cd %s && %s > %s 2>&1" % (self.build_dir, @@ -109,6 +110,7 @@ self.compiler.make_opts, build_log)) result, elapsed = run_cmd(cmd) + sys.stdout.flush() return elapsed diff -Naur distcc-2.18.3/bench/compiler.py distcc-2.18.3.new/bench/compiler.py --- distcc-2.18.3/bench/compiler.py 2004-07-29 18:12:13.000000000 -0700 +++ distcc-2.18.3.new/bench/compiler.py 2006-01-03 18:04:18.000000000 -0800 @@ -51,10 +51,15 @@ cc='cc', cxx='c++', make_opts='-j%d' % howmany) - elif where == 'dist': + elif where[0:4] == 'dist': return CompilerSpec(name='dist_%02d' % howmany, - cxx='distcc c++', - cc='distcc cc', + cxx='distcc %s++' % where[4:], + cc='distcc %scc' % where[4:], + make_opts='-j%d' % howmany) + elif where[0:6] == 'ccache': + return CompilerSpec(name='ccache_%02d' % howmany, + cxx='ccache %s++' % where[6:], + cc='ccache %scc' % where[6:], make_opts='-j%d' % howmany) else: raise ValueError, ("don't understand %s" % `where`) diff -Naur distcc-2.18.3/scripts/analy.sh distcc-2.18.3.new/scripts/analy.sh --- distcc-2.18.3/scripts/analy.sh 1969-12-31 16:00:00.000000000 -0800 +++ distcc-2.18.3.new/scripts/analy.sh 2006-01-03 18:05:49.000000000 -0800 @@ -0,0 +1,28 @@ +#!/bin/sh +# $1 = number of runs of distcc +# $2 = script_dir +# $3 = result_dir +# $4 = tmp_result_table +# $5 = result_table +# $6 = num_iter + +perl $2/avg.pl $3/res_local_01 1 "local" 1 > $4 + +perl $2/avg.pl $3/res_ccache_1 $6 "ccache" 1 >> $4 + +perl $2/avg.pl $3/res_ccache_2 $6 "ccache" 2 >> $4 + +perl $2/avg.pl $3/res_ccache_distcc_1_08 $6 "ccache+distcc" 1 >> $4 + +perl $2/avg.pl $3/res_ccache_distcc_2_08 $6 "ccache+distcc" 2 >> $4 + +for ((j=1; j <= $1; j++)) do + perl $2/avg.pl $3/res_distcc_${j}_04 $6 "distcc-j4" $j >> $4 +done + +for ((j=1; j <= $1; j++)) do + perl $2/avg.pl $3/res_distcc_${j}_08 $6 "distcc-j8" $j >> $4 +done + +perl $2/stats.pl $4 $5 $6 + diff -Naur distcc-2.18.3/scripts/avg.pl distcc-2.18.3.new/scripts/avg.pl --- distcc-2.18.3/scripts/avg.pl 1969-12-31 16:00:00.000000000 -0800 +++ distcc-2.18.3.new/scripts/avg.pl 2006-01-03 18:05:49.000000000 -0800 @@ -0,0 +1,38 @@ +#!/usr/bin/perl + +$file = $ARGV[0]; +open INFILE, "< $file" or die "Couldn't open $file"; +local $/=undef; +$slurp = ; +$res_avg = 0; +close INFILE; + +@builds = split m/Building/, $slurp; +foreach $build (@builds) { + if (substr($build,0,3) eq "\.\.\.") { + if ($build =~ m/\/bench\/build\/(.*?)\//) { + $bench_name = $1; + @sub_builds = split m/DISTCC_LOG=/, $build; + if ($sub_builds[1] =~ m/(\d+\.\d*)s elapsed/) { + push @{ $results{$bench_name} }, $1; + } + + } + } +} + + +for $result ( keys %results ) { + $k = 0; + foreach $j ( 0 .. $#{ $results{$result} }) { + $avg{$result} += $results{$result}[$j]; + $k++; + } + $num{$result} = $k; +} +for $i (keys %avg) { + #$number = sprintf("%.1f",$avg{$i}/$ARGV[1]); + $number = sprintf("%.1f",$avg{$i}/$num{$i}); + print "$i \t", $number, "s\trun$ARGV[3]\t$ARGV[2]\t$num{$i}\n"; +} +print "\n"; diff -Naur distcc-2.18.3/scripts/cleancache.sh distcc-2.18.3.new/scripts/cleancache.sh --- distcc-2.18.3/scripts/cleancache.sh 1969-12-31 16:00:00.000000000 -0800 +++ distcc-2.18.3.new/scripts/cleancache.sh 2006-01-03 18:05:49.000000000 -0800 @@ -0,0 +1,8 @@ +# $1 distcc_hosts_cache + +# hard coded $distcc_cache_dir, since the rm stmt below is too dangerous +distcc_cache_dir="/tmp/dcc_cache" + +for host in $1; do + ssh -n -x -T -l root $host rm -rf $distcc_cache_dir/\???* +done diff -Naur distcc-2.18.3/scripts/kill_server.sh distcc-2.18.3.new/scripts/kill_server.sh --- distcc-2.18.3/scripts/kill_server.sh 1969-12-31 16:00:00.000000000 -0800 +++ distcc-2.18.3.new/scripts/kill_server.sh 2006-01-03 18:05:49.000000000 -0800 @@ -0,0 +1,15 @@ +# $1 distcc_hosts + +HOSTS=$1 + +for host in $HOSTS; do + pid=`ssh -n -x -T -l root $host ps -ef | grep distccd | grep -v grep| awk -F' ' '{print $2}'`; + if test "$pid" == ""; then + echo "distccd server is not runing"; + else + echo $pid; + echo "Killing process ..." + ssh -n -x -T -l root $host kill $pid; + fi +done + diff -Naur distcc-2.18.3/scripts/reload_server.sh distcc-2.18.3.new/scripts/reload_server.sh --- distcc-2.18.3/scripts/reload_server.sh 1969-12-31 16:00:00.000000000 -0800 +++ distcc-2.18.3.new/scripts/reload_server.sh 2006-01-03 18:05:49.000000000 -0800 @@ -0,0 +1,18 @@ +# $1 distcc_hosts +# $2 distcc_allow_file +# $3 distcc_server_org +# $4 distcc_server_options +HOSTS=$1 + +for host in $HOSTS; do + scp $3 root@${host}:/usr/bin/ + OPTIONS="$4" + ALLOW_OPTIONS=`sed 's/^/--allow=/' < $2` + USER=distcc + prog="distccd" + TMPDIR="/var/tmp/distcc" + ssh -n -x -T -l root $host mkdir -p $TMPDIR + ssh -n -x -T -l root $host chown $USER $TMPDIR/. + ssh -n -x -T -l root $host rm -rf $TMPDIR/. + ssh -n -x -T -l root $host $prog $OPTIONS $ALLOW_OPTIONS +done diff -Naur distcc-2.18.3/scripts/run.sh distcc-2.18.3.new/scripts/run.sh --- distcc-2.18.3/scripts/run.sh 1969-12-31 16:00:00.000000000 -0800 +++ distcc-2.18.3.new/scripts/run.sh 2006-01-03 18:05:49.000000000 -0800 @@ -0,0 +1,135 @@ +#!/bin/sh + +# $1 = how many times you want to run each individual experiment +# $2 = project list, if this one is empty, all projects will be run + +# 3 environment variables must be set before run this experiment +# DISTCC_HOSTS +# DISTCC_CROSS_COMPILE +# DISTCC_ALLOW_FILE + +# DISTCCD_CROSS_COMPILE should be set as well if it is different from DISTCC_CROSS_COMPILE +# otherwise, DISTCC_CROSS_COMPILE will be used as DISTCCD_CROSS_COMPILE. + +if test "$1" = "--help" || test "$1" = "-h"; then + echo "Usage: $0 num_times [project list]" + echo "Where num_times is the number of times you want to run each individual distcc experiment" + echo "[project list] is the list of project you want to run, if \$2 is omitted, by default, run all." + exit 0 +fi + +set -x +set -e + +function abort() { + echo $@ + exit 1 +} + +test "$DISTCC_HOSTS" != "" || abort "error: \$DISTCC_HOSTS must be set" +test "$DISTCC_CROSS_COMPILE" != "" || abort "error: \$DISTCC_CROSS_COMPILE must be set" +test "$DISTCC_ALLOW_FILE" != "" || abort "error: \$DISTCC_ALLOW_FILE must be set" + +test "$DISTCCD_CROSS_COMPILE" != "" || DISTCCD_CROSS_COMPILE=$DISTCC_CROSS_COMPILE + +tmp_top=`pwd` +scripts_dir="$tmp_top/scripts" +run_orig=1 + +if test "`expr substr \"$DISTCC_HOSTS\" 1 9`" = "--sharded"; then + run_orig=0 + distcc_hosts_cache=$DISTCC_HOSTS +fi + +if test $run_orig = 0 +then + distcc_hosts_orig=`echo $DISTCC_HOSTS | sed 's/[^ ]* //'` +else + distcc_hosts_orig="$DISTCC_HOSTS" +fi + +#deploy distccd server +sh $scripts_dir/kill_server.sh "$distcc_hosts_orig" + +cd $tmp_top + +CC=${DISTCCD_CROSS_COMPILE}gcc \ +CXX=${DISTCCD_CROSS_COMPILE}g++ \ +AR=${DISTCCD_CROSS_COMPILE}ar \ +RANLIB=${DISTCCD_CROSS_COMPILE}ranlib \ +./configure +make + +if test $run_orig = 1 ; then + sh $scripts_dir/reload_server.sh "$distcc_hosts_orig" "$DISTCC_ALLOW_FILE" "$tmp_top/distccd" "--daemon" +else + sh $scripts_dir/reload_server.sh "$distcc_hosts_orig" "$DISTCC_ALLOW_FILE" "$tmp_top/distccd" "--daemon --cache" +fi + + +result_dir="$tmp_top/results" +tmp_result_table="$result_dir/tmp_result_table" +result_table="$result_dir/result_table.html" + +rm -rf $result_dir +mkdir -p $result_dir + +distcc_dir=$tmp_top/distcc_dir +rm -rf $distcc_dir +mkdir -p $distcc_dir + +#run original local compile +cd $tmp_top/bench +./benchmark.py --compiler="local,1" $2 >> $result_dir/res_local_01 + +export DISTCC_DIR="$distcc_dir" + +export PATH="$tmp_top:${PATH}" + +num_iter=5 + +for ((i = 0; i < $num_iter; i++)); do + + # run ccache local compile + cd $tmp_top/bench + ccache_dir="$tmp_top/ccache_dir" + mkdir -p $ccache_dir + export CCACHE_DIR=$ccache_dir + unset CCACHE_PREFIX + rm -rf $ccache_dir/* + # run ccache 1st time + ./benchmark.py --compiler="ccache ${DISTCC_CROSS_COMPILE}g,1" $2 >> $result_dir/res_ccache_1 + # run ccache 2nd time + ./benchmark.py --compiler="ccache ${DISTCC_CROSS_COMPILE}g,1" $2 >> $result_dir/res_ccache_2 + + # run distcc with ccache + export CCACHE_PREFIX="distcc" + rm -rf $ccache_dir/* + # run ccache 1st time + ./benchmark.py --compiler="ccache ${DISTCC_CROSS_COMPILE}g,8" $2 >> $result_dir/res_ccache_distcc_1_08 + # run ccache 2nd time + ./benchmark.py --compiler="ccache ${DISTCC_CROSS_COMPILE}g,8" $2 >> $result_dir/res_ccache_distcc_2_08 + + if test $run_orig = 0; then + sh $tmp_top/scripts/cleancache.sh "$distcc_hosts_orig" + fi + for ((j = 1; j <= $1; j++)); do + ./benchmark.py --compiler="dist ${DISTCC_CROSS_COMPILE}g,4" $2 >> $result_dir/res_distcc_${j}_04 + done + + if test $run_orig = 0; then + sh $tmp_top/scripts/cleancache.sh "$distcc_hosts_orig" + fi + for ((j = 1; j <= $1; j++)); do + ./benchmark.py --compiler="dist ${DISTCC_CROSS_COMPILE}g,8" $2 >> $result_dir/res_distcc_${j}_08 + done + + +done + + +# analysis + +script_dir=$tmp_top/scripts + +sh $script_dir/analy.sh $1 $script_dir $result_dir $tmp_result_table $result_table $num_iter diff -Naur distcc-2.18.3/scripts/stats.pl distcc-2.18.3.new/scripts/stats.pl --- distcc-2.18.3/scripts/stats.pl 1969-12-31 16:00:00.000000000 -0800 +++ distcc-2.18.3.new/scripts/stats.pl 2006-01-03 18:05:49.000000000 -0800 @@ -0,0 +1,95 @@ +#!/usr/bin/perl + +$infile = $ARGV[0]; +$outfile = $ARGV[1]; + +open INFILE, "<$infile" or die "Couldn't open $infile"; +open OUTFILE, ">$outfile" or die "Couldn't open $outfile"; +printf OUTFILE "\n"; +printf OUTFILE "\n"; +printf OUTFILE "distcc benchmark result\n"; +printf OUTFILE "\n"; +printf OUTFILE "

distcc benchmark result

\n"; +printf OUTFILE "

The results are given in seconds reported by distcc-2.18.3/bench/Build.py, and averaged over $ARGV[2] run(s). Smaller is better.

"; +printf OUTFILE "\n"; + + +$i = 0; +$first = 1; +$runs[0] = "bench"; + +while ($line = ) { + if ($line =~ m/^\n/) { + $first = 1; + $i++; + } else { + @benches = split m/\t/, $line; + if ($first == 1) { + $first = 0; + $runs[$i+1] = sprintf("%s %s", $benches[3],$benches[2]); + } + $bench_name = $benches[0]; + $time = $benches[1]; + push @{ $results{$bench_name} }, $time; +# push @{ $norm_results{$bench_name} }, $time; + } +} +#print table column name +printf OUTFILE ""; +$i++; +for ($j = 0; $j < $i; $j++) { + printf OUTFILE ""; +} +printf OUTFILE "\n"; + +#print table content +#for $result (keys %results){ +$k = 0; +foreach $result (sort { $results{$a}[0] <=> $results{$b}[0] } keys %results){ + printf OUTFILE ""; + printf OUTFILE ""; + $norm_results[$k][0]=$result; + foreach $j (0 .. $#{ $results{$result} }) { + $ratio = sprintf("%.1f",$results{$result}[$j]); + printf OUTFILE ""; + $norm_results[$k][$j+1] = $results{$result}[$j]/$results{$result}[0]; +# $norm_results{$result}[$j] /= $results{$result}[0]; +# push @{ $norm_results{$result} }, $results{$result}[$j]/$results{$result}[0]; + } + $k++; + printf OUTFILE "\n"; +} +close(INFILE); +printf OUTFILE "
$runs[$j]
$result$ratio
\n"; + + +printf OUTFILE "

Normalized results against local build (each column is divided by local run1). Smaller is better.

"; +printf OUTFILE "\n"; +for ($j = 0; $j < $i; $j++) { + printf OUTFILE ""; +} +printf OUTFILE "\n"; + +#print table content +for $k ( 0 .. $#norm_results ) { + printf OUTFILE ""; + printf OUTFILE ""; + for $j ( 1 .. $#{$norm_results[$k]} ) { + $ratio = sprintf("%.2f",$norm_results[$k][$j]); + printf OUTFILE ""; + } +} +#for $result (keys %norm_results){ +# printf OUTFILE ""; +# printf OUTFILE ""; +# foreach $j (0 .. $#{ $norm_results{$result} }) { +# $ratio = sprintf("%.2f",$norm_results{$result}[$j]); +# printf OUTFILE ""; +# } +# printf OUTFILE "\n"; +#} +printf OUTFILE "
$runs[$j]
$norm_results[$k][0]$ratio
$result$ratio
\n"; + +printf OUTFILE "\n"; +printf OUTFILE ""; +close(OUTFILE);