Update benchmark script to run a few other cases.
[bluesky.git] / microbench / run.sh
1 #!/bin/bash
2 #
3 # Run a set of benchmarks on the NFS frontend and report performance.
4
5 source "$HOME/bin/aws-keys"
6 BLUESKY="$HOME/local/bluesky.git"
7 NFSD="$BLUESKY/nfs3/nfsproxy"
8
9 SIZES="32 64 128 256 512 512 1024 1536 2048 2560 3072 3584 4096 5120 6144 7168 8192"
10
11 die() {
12     echo "FATAL ERROR: $@"
13     exit 1
14 }
15
16 run_setup() {
17     echo "Starting nfsproxy..." 1>&2
18     $NFSD &
19     NFSPID=$!
20     sleep 0.5
21     sudo mount -t nfs -o tcp,hard,intr,vers=3 localhost:/bluesky /mnt/bluesky || die "Mounting NFS"
22 }
23
24 run_cleanup() {
25     echo "Stopping nfsproxy..." 1>&2
26     sudo umount -f /mnt/bluesky
27     kill -TERM $NFSPID
28     wait $NFSPID
29 }
30
31 benchmark_setup() {
32     echo "Checking for sudo access..." 1>&2
33     sudo whoami
34     echo "Preparing for benchmark run..." 1>&2
35     s3cmd -r --force del s3://mvrable-bluesky
36     run_setup
37     for i in {1..64}; do
38         dd if=/dev/urandom of=/mnt/bluesky/file-$i bs=32k count=1
39     done
40     for s in $SIZES; do
41         dd if=/dev/urandom of=/mnt/bluesky/size-$s bs=1k count=$s
42     done
43     sleep 15
44     run_cleanup
45 }
46
47 benchmark_cleanup() {
48     echo "Cleaning up from benchmark runs..." 1>&2
49 }
50
51 run_thread_test() {
52     run_setup
53     echo "Running test" 1>&2
54     (cd /mnt/bluesky; $BLUESKY/microbench/statbench "$@") >results-t$1-s$BLUESKY_OPT_SYNC_FRONTENDS
55     run_cleanup
56
57     run_setup
58     echo "Running synthetic test" 1>&2
59     ($BLUESKY/nfs3/synclient "$@") >results-t$1s-s$BLUESKY_OPT_SYNC_FRONTENDS
60     run_cleanup
61 }
62
63 benchmark_setup
64
65 for s in $SIZES; do
66     run_setup
67     echo "Running read test $s" 1>&2
68     (cd /mnt/bluesky; $BLUESKY/microbench/readbench size-$s) >results-large$s-t1
69     run_cleanup
70 done
71
72 if false; then
73 export BLUESKY_OPT_SYNC_FRONTENDS=0
74 for t in 1 2 4 6 8 10 12 14 16 20 24 28 32 40 48 56 64; do
75     run_thread_test $t
76 done
77
78 export BLUESKY_OPT_SYNC_FRONTENDS=1
79 for t in 1 2 4 6 8 10 12 14 16 20 24 28 32 40 48 56 64; do
80     run_thread_test $t
81 done
82 fi
83
84 benchmark_cleanup