# HG changeset patch # User Francisco J Ballesteros # Date 1327742015 0 # Node ID d17cf85e7095cbf01fd7be1c574ce3a717133957 # Parent 5e1f4021aede931ec139864d8891886e9403d62c bench: tools for experiments R=nixiedev, john, nemo CC=nix-dev http://codereview.appspot.com/5574076 diff -r 5e1f4021aede -r d17cf85e7095 sys/src/nix/bench/1/kern --- a/sys/src/nix/bench/1/kern Sat Jan 28 09:11:55 2012 +0000 +++ b/sys/src/nix/bench/1/kern Sat Jan 28 09:13:35 2012 +0000 @@ -6,9 +6,12 @@ # . ../tools -# we might have a main.c file here and do something like: -# bind main.c ../../k10/main.c +# we might have a source file here and do something like: # to override the source used for this benchmark +bind proc.c ../../port/proc.c + +cp /cfg/pxe/003048ff2106 pxeorig +cp 003048ff2106 /cfg/pxe # we might change the std source like this: # sed 's/initialTCs = [0-9]+/initialTCs = 16/' < ../../k10/main.c >main.c diff -r 5e1f4021aede -r d17cf85e7095 sys/src/nix/bench/1/runbench --- a/sys/src/nix/bench/1/runbench Sat Jan 28 09:11:55 2012 +0000 +++ b/sys/src/nix/bench/1/runbench Sat Jan 28 09:13:35 2012 +0000 @@ -1,15 +1,26 @@ #!/bin/rc +# +# kernel as of /n/nixdump/2012/0119/sys/src/nix/bench +# Single sched, 32 TCs. +# Time to make a kernel +# + rfork ne +# restore the pxe file we saved +cp pxeorig /cfg/pxe/003048ff2106 + # import rc functions popular among scripts, e.g. fail # . ../tools -# How much time does it take to sleep 2? -../Time 'sleep 2' +# How much time does it take to make a kernel +../Time 'cd /sys/src/nix/k10 ; mk clean ; mk' + # What's the value for measures taken from the kernel? -echo '#cat /dev/debug' -cat /dev/debug +# echo '#cat /dev/debug' +# cat /dev/debug +# NB: this is an example. /dev/debug is reported already by Time diff -r 5e1f4021aede -r d17cf85e7095 sys/src/nix/bench/Benchs --- a/sys/src/nix/bench/Benchs Sat Jan 28 09:11:55 2012 +0000 +++ b/sys/src/nix/bench/Benchs Sat Jan 28 09:13:35 2012 +0000 @@ -2,10 +2,14 @@ # change the boot sequence to run benchs. -# remove stale state from benchs if given -a -if(~ $#* 1 && ~ $1 -a) - rm -f [0-9]*/^(koutput output FAIL) k[0-9]*/^(koutput output FAIL) +# remove output from all benchs: +# rm -f [0-9]*/^(koutput output FAIL KMESG) k[0-9]*/^(koutput output FAIL KMESG) + +# remove output from some benchs, to rerun them: +# for(t in 93 94 95) rm -f $t/^(koutput output FAIL KMESG) + # arrange for them to run after rebooting cp runbenchs /cfg/$sysname/runbenchs -reboot +runbenchs + diff -r 5e1f4021aede -r d17cf85e7095 sys/src/nix/bench/Locks --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/src/nix/bench/Locks Sat Jan 28 09:13:35 2012 +0000 @@ -0,0 +1,29 @@ +#!/bin/rc +rfork e +cmd=$1 +echo '#' $1 +echo measuring $1... >'#c/cons' +rm -f /tmp/bench.time +rc -c $cmd >'#c/cons' # warm cache and be able to see the output of the cmd... +# +# collect stats. A single run this time. +# +echo >/dev/sysstat +bind -a '#W' /dev +echo start >/dev/wsctl +time rc -c $cmd >/dev/null >>[2]/tmp/bench.time +echo stop >/dev/wsctl +cp /dev/wsdata /tmp/wsdata +cp /dev/sysstat /tmp/sysstat +tail -1 /tmp/bench.time +tail -1 /tmp/bench.time >'#c/cons' +sed 's/[sur]//g' $d/003048ff2106}} + +Then run ./Benchs + +for(x in `{seq 30}){ d=`{echo $x + 67|hoc} ; nc=`{echo $x + 2 | hoc}; echo dir $d echo $nc cores ; ; sed 's/ck 2$/ck '^$nc^'/' < 67/003048ff2106 >$d/003048ff2106} + +Beware that many benchs are made assuming the kernel is implemented in a +certain way, at least, those depending on a particular kernel. +That means that, for example, if you clear benchs 1-99, you might have to +rely on /n/nixdump/2012/0123/sys/src/nix sources; otherwise the kernel might +not compile, or you might be measuring something else. + +In short: feel free to clear only the benchmarks you are responsible for. +You should know what you are measuring in any case. diff -r 5e1f4021aede -r d17cf85e7095 sys/src/nix/bench/Time --- a/sys/src/nix/bench/Time Sat Jan 28 09:11:55 2012 +0000 +++ b/sys/src/nix/bench/Time Sat Jan 28 09:13:35 2012 +0000 @@ -4,14 +4,20 @@ echo '#' $1 echo measuring $1... >'#c/cons' rm -f /tmp/bench.time +rc -c $cmd >'#c/cons' # warm cache and be able to see the output of the cmd... +echo >/dev/sysstat for(i in `{seq 10}){ time rc -c $cmd >/dev/null >>[2]/tmp/bench.time tail -1 /tmp/bench.time tail -1 /tmp/bench.time >'#c/cons' } +cp /dev/sysstat /tmp/sysstat sed 's/[sur]//g' koutput >[2=1]){ touch FAIL fail bench $t failed } reboot } + if(test -x kern) + cp /dev/kmesg KMESG if(! runbench>output >[2=1]){ touch FAIL fail bench $t failed diff -r 5e1f4021aede -r d17cf85e7095 sys/src/nix/bench/tools --- a/sys/src/nix/bench/tools Sat Jan 28 09:11:55 2012 +0000 +++ b/sys/src/nix/bench/tools Sat Jan 28 09:13:35 2012 +0000 @@ -7,3 +7,31 @@ echo $* echo $* >/dev/cons } + + +fn repeatforallnumcores { + test -e kern || fail no kernel bench + test -e 003048ff2106 || fail no pxe file + test -e koutput || fail no koutput + test -e output || fail no output + + NC=`{grep '^bootfile' 003048ff2106 | awk '{print $NF}'} + if(~ $NC 32){ + cp output output.32 + cp KMESG KMESG.32 + exit '' + } + @{ + NNC=`{echo $NC + 1|hoc} + mv 003048ff2106 003048ff2106_ + sed 's/-ck .*/-ck '^$NNC^' '^$NNC^'/' < 003048ff2106_ >003048ff2106 + + mv output output.$NC + mv KMESG KMESG.$NC + cp 003048ff2106 /cfg/pxe +# mv koutput koutput.$NC + echo reboot to run `{pwd} with $NNC cores... + reboot + @} >'#c/cons' >[2]'#c/cons' + status='' +}