# HG changeset patch # User Francisco J Ballesteros # Date 1327009711 0 # Node ID 55a88db0000a61830171708124805f1aa47f5785 # Parent 70c782122c8862200831797c7dcc270a1c649e2e new: benchmarking scripts R=nixiedev, john CC=nix-dev http://codereview.appspot.com/5557046 Committer: John Floren diff -r 70c782122c88 -r 55a88db0000a sys/src/nix/bench/1/kern --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/src/nix/bench/1/kern Thu Jan 19 21:48:31 2012 +0000 @@ -0,0 +1,19 @@ +#!/bin/rc + +rfork ne + +# import rc functions popular among scripts, e.g. fail +# +. ../tools + +# we might have a main.c file here and do something like: +# bind main.c ../../k10/main.c +# to override the source used for this benchmark + +# we might change the std source like this: +# sed 's/initialTCs = [0-9]+/initialTCs = 16/' < ../../k10/main.c >main.c +# bind main.c ../../k10/main.c + +cd /sys/src/nix/k10 +mk clean +mk install diff -r 70c782122c88 -r 55a88db0000a sys/src/nix/bench/1/output --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/src/nix/bench/1/output Thu Jan 19 21:48:31 2012 +0000 @@ -0,0 +1,20 @@ +# sleep 2 +0.00u 0.02s 2.02r rc -c sleep 2 +0.00u 0.03s 2.02r rc -c sleep 2 +0.00u 0.02s 2.02r rc -c sleep 2 +0.00u 0.01s 2.03r rc -c sleep 2 +0.00u 0.03s 2.02r rc -c sleep 2 +0.00u 0.02s 2.02r rc -c sleep 2 +0.00u 0.02s 2.02r rc -c sleep 2 +0.00u 0.04s 2.02r rc -c sleep 2 +0.00u 0.02s 2.02r rc -c sleep 2 +0.00u 0.04s 2.03r rc -c sleep 2 +times 0 0.025 2.022 +#cat /dev/debug +steal 1 +donate 0 +locks 965080 +glare 6450 +inglare 8840 +qlock 73101 +qlockq 66 diff -r 70c782122c88 -r 55a88db0000a sys/src/nix/bench/1/runbench --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/src/nix/bench/1/runbench Thu Jan 19 21:48:31 2012 +0000 @@ -0,0 +1,15 @@ +#!/bin/rc + +rfork ne + +# import rc functions popular among scripts, e.g. fail +# +. ../tools + +# How much time does it take to sleep 2? +../Time 'sleep 2' + +# What's the value for measures taken from the kernel? +echo '#cat /dev/debug' +cat /dev/debug + diff -r 70c782122c88 -r 55a88db0000a sys/src/nix/bench/Benchs --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/src/nix/bench/Benchs Thu Jan 19 21:48:31 2012 +0000 @@ -0,0 +1,11 @@ +#!/bin/rc + +# 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) + +# arrange for them to run after rebooting +cp runbenchs /cfg/$sysname/runbenchs +reboot diff -r 70c782122c88 -r 55a88db0000a sys/src/nix/bench/README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/src/nix/bench/README Thu Jan 19 21:48:31 2012 +0000 @@ -0,0 +1,53 @@ +This is performance measurement for nix. + +Each directory named with a number represents a single measure to be taken. +(e.g., 1/ 2/ ...) +A bench directory may be also named k1, k2, k.... +All k benchs run affter all std. benchs. They are meant to install ad-hoc +kernels for measurement. + +The script actually running the benchs is runbenchs, which should be run from +cpustart during the machine boot process only if it's found at /cfg/$sysname +That is, include + test -x /cfg/$sysname/runbenchs && /cfg/$sysname/runbenchs +in your cpustart file. + +It is not meant to start the bench sequence by hand. +To (re)run all the benchmarks, you should run ./Benchs instead. + +See 1/ for a template. Copy it to your own and tweak it at will. + +To start benchs, run the script ./Benchs in clu, which would +change the boot sequence such that the machine starts to run benchs +(perhaps installing different kernels and rebooting) until all ones +have been run or one has failed. + +Each directory must contain: + +- kern: a script used to compile and install a kernel. + if no such file is found, no new kernel is installed. the current one + is used. Otherwise, the indicated kernel is installed and the machine + reboots using this kernel. + +- runbench: a script used to run a bench. This is mandatory. + +- whichever other files must be available for the benchs to run. + +Benchs generate within each test directory whichever files they want. +By convention, repeated times measured get into TIMES, and debug counters +get into COUNTERS. The last line in TIMES reports the average. +Repeated timing is done by Time. See the bench in ./1 as a template. + + +As a result of running an to control when to run them, these files are +generated: +- koutput: a file keeping the output for a kern that did run +- output: a file keeping the output for a test that did run +- FAIL: an empty file, reporting that a test did fail. + + +BEWARE that if you install a kernel for a bench then that kernel is used +for all following ones. +As a convention, benchs installing a kernel should be named k0, k1, ... +test 1 installs the std kernel, so that all benchs use the regular kernel. + diff -r 70c782122c88 -r 55a88db0000a sys/src/nix/bench/Time --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/src/nix/bench/Time Thu Jan 19 21:48:31 2012 +0000 @@ -0,0 +1,17 @@ +#!/bin/rc +rfork e +cmd=$1 +echo '#' $1 +echo measuring $1... >'#c/cons' +rm -f /tmp/bench.time +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' +} +sed 's/[sur]//g' koutput >[2=1]){ + touch FAIL + fail bench $t failed + } + reboot + } + if(! runbench>output >[2=1]){ + touch FAIL + fail bench $t failed + } + echo bench $t ok + } + } + cd .. +} +if(! ~ $#failed 0) + echo benchs $failed failed +if not + echo all benchs done + +rm /cfg/$sysname/runbenchs diff -r 70c782122c88 -r 55a88db0000a sys/src/nix/bench/tools --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sys/src/nix/bench/tools Thu Jan 19 21:48:31 2012 +0000 @@ -0,0 +1,9 @@ +fn fail { + echo $* >[1=2] + exit fail +} + +fn log { + echo $* + echo $* >/dev/cons +}