9c40e0de995be21cbda3c95e7191a03ea8f02f6c
[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 die() {
10     echo "FATAL ERROR: $@"
11     exit 1
12 }
13
14 run_setup() {
15     echo "Starting nfsproxy..." 1>&2
16     $NFSD &
17     NFSPID=$!
18     sleep 0.5
19     sudo mount -t nfs -o tcp,hard,intr localhost:/bluesky /mnt/bluesky || die "Mounting NFS"
20 }
21
22 run_cleanup() {
23     echo "Stopping nfsproxy..." 1>&2
24     sudo umount -f /mnt/bluesky
25     kill -TERM $NFSPID
26     wait $NFSPID
27 }
28
29 benchmark_setup() {
30     echo "Checking for sudo access..." 1>&2
31     sudo whoami
32     echo "Preparing for benchmark run..." 1>&2
33     $HOME/docs/2009/fall/s3test/s3-cleanup.py mvrable-bluesky
34     run_setup
35     for i in {1..64}; do
36         dd if=/dev/urandom of=/mnt/bluesky/file-$i bs=32k count=1
37     done
38     sleep 15
39     run_cleanup
40 }
41
42 benchmark_cleanup() {
43     echo "Cleaning up from benchmark runs..." 1>&2
44 }
45
46 run_test() {
47     run_setup
48     echo "Running test" 1>&2
49     (cd /mnt/bluesky; $BLUESKY/microbench/readbench "$@") >results-t$1-s$BLUESKY_OPT_SYNC_FRONTENDS
50     run_cleanup
51
52     run_setup
53     echo "Running synthetic test" 1>&2
54     ($BLUESKY/nfs3/synclient "$@") >results-t$1s-s$BLUESKY_OPT_SYNC_FRONTENDS
55     run_cleanup
56 }
57
58 benchmark_setup
59
60 export BLUESKY_OPT_SYNC_FRONTENDS=0
61 for t in 1 2 4 6 8 10 12 14 16 20 24 28 32 40 48 56 64; do
62     run_test $t
63 done
64
65 export BLUESKY_OPT_SYNC_FRONTENDS=1
66 for t in 1 2 4 6 8 10 12 14 16 20 24 28 32 40 48 56 64; do
67     run_test $t
68 done
69
70 benchmark_cleanup