From d5e3f485ae432ebe37299c2effca09173b9f74d0 Mon Sep 17 00:00:00 2001 From: Michael Vrable Date: Tue, 2 Feb 2010 13:04:52 -0800 Subject: [PATCH] Add scripts for automatically testing reads at different settings. --- microbench/mean.py | 15 ++++++++++ microbench/readbench.c | 15 ++++++++-- microbench/run.sh | 65 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 3 deletions(-) create mode 100755 microbench/mean.py create mode 100755 microbench/run.sh diff --git a/microbench/mean.py b/microbench/mean.py new file mode 100755 index 0000000..d567e52 --- /dev/null +++ b/microbench/mean.py @@ -0,0 +1,15 @@ +#!/usr/bin/python +# +# Print mean and standard deviation of a series of numbers read from stdin. + +import sys + +inputs = ''.join(sys.stdin.readlines()).split() +vals = map(float, inputs) +mean = sum(vals) / len(vals) +if len(vals) > 1: + stddev = (sum((x - mean)**2 for x in vals) / (len(vals) - 1)) ** 0.5 +else: + stddev = 0.0 + +print "%s\t%s" % (mean, stddev) diff --git a/microbench/readbench.c b/microbench/readbench.c index 88eb888..84d6a82 100644 --- a/microbench/readbench.c +++ b/microbench/readbench.c @@ -55,7 +55,7 @@ void *benchmark_thread(void *arg) struct thread_state *ts = (struct thread_state *)arg; char namebuf[64]; - sprintf(namebuf, "file-%d", ts->thread_num); + sprintf(namebuf, "file-%d", ts->thread_num + 1); printf("Opening %s\n", namebuf); int64_t start, end; @@ -96,11 +96,20 @@ void wait_thread(int n) int main(int argc, char *argv[]) { - for (int i = 0; i < 8; i++) { + int threads = 8; + + if (argc > 1) + threads = atoi(argv[1]); + if (threads > MAX_THREADS) + threads = MAX_THREADS; + + printf("Testing with %d threads\n", threads); + + for (int i = 0; i < threads; i++) { launch_thread(i); } - for (int i = 0; i < 8; i++) { + for (int i = 0; i < threads; i++) { wait_thread(i); } diff --git a/microbench/run.sh b/microbench/run.sh new file mode 100755 index 0000000..f122370 --- /dev/null +++ b/microbench/run.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# Run a set of benchmarks on the NFS frontend and report performance. + +source "$HOME/bin/aws-keys" +BLUESKY="$HOME/local/bluesky.git" +NFSD="$BLUESKY/nfs3/nfsproxy" + +die() { + echo "FATAL ERROR: $@" + exit 1 +} + +run_setup() { + echo "Starting nfsproxy..." 1>&2 + $NFSD & + NFSPID=$! + sleep 0.5 + sudo mount -t nfs -o tcp,hard,intr localhost:/bluesky /mnt/bluesky || die "Mounting NFS" +} + +run_cleanup() { + echo "Stopping nfsproxy..." 1>&2 + sudo umount -f /mnt/bluesky + kill -TERM $NFSPID + wait $NFSPID +} + +benchmark_setup() { + echo "Checking for sudo access..." 1>&2 + sudo whoami + echo "Preparing for benchmark run..." 1>&2 + $HOME/docs/2009/fall/s3test/s3-cleanup.py mvrable-bluesky + run_setup + for i in {1..64}; do + dd if=/dev/urandom of=/mnt/bluesky/file-$i bs=32k count=1 + done + sleep 15 + run_cleanup +} + +benchmark_cleanup() { + echo "Cleaning up from benchmark runs..." 1>&2 +} + +run_test() { + run_setup + echo "Running test" 1>&2 + (cd /mnt/bluesky; $BLUESKY/microbench/readbench "$@") >results-t$1-s$BLUESKY_OPT_SYNC_FRONTENDS + run_cleanup +} + +benchmark_setup + +export BLUESKY_OPT_SYNC_FRONTENDS=0 +for t in 1 2 4 6 8 10 12 14 16 20 24 28 32 40 48 56 64; do + run_test $t +done + +export BLUESKY_OPT_SYNC_FRONTENDS=1 +for t in 1 2 4 6 8 10 12 14 16 20 24 28 32 40 48 56 64; do + run_test $t +done + +benchmark_cleanup -- 2.20.1