From: Michael Vrable Date: Sun, 20 Feb 2011 04:28:46 +0000 (-0800) Subject: More reworking of microbenchmark handling of reads/writes and file layout. X-Git-Url: http://git.vrable.net/?a=commitdiff_plain;ds=sidebyside;h=0e57b9b0865caf4b47deadbc17ef46bca4ea98d2;p=bluesky.git More reworking of microbenchmark handling of reads/writes and file layout. --- diff --git a/microbench/mixedbench.c b/microbench/mixedbench.c index 0447fd1..a93d5f9 100644 --- a/microbench/mixedbench.c +++ b/microbench/mixedbench.c @@ -92,16 +92,30 @@ void benchmark_op(struct thread_state *ts) start = now_hires(); - char filename[256]; - int n = get_random(opt_filecount); + /* The space of all files is partitioned evenly based on the number of + * threads. Pick a file out of our particular partition. */ + int thread_num, thread_count; + if (ts->thread_num >= write_threads) { + /* Read */ + thread_num = ts->thread_num - write_threads; + thread_count = opt_threads - write_threads; + } else { + /* Write */ + thread_num = ts->thread_num; + thread_count = write_threads; + } + + int n = get_random(opt_filecount / thread_count); + n += thread_num * (opt_filecount / thread_count); int n1 = n / opt_dirsize, n2 = n % opt_dirsize; + char filename[256]; + sprintf(filename, "%d/%d", n1, n2); if (ts->thread_num >= write_threads) { /* Read */ - sprintf(filename, "t%d/%d/%d", ts->thread_num - write_threads, n1, n2); FILE *f = fopen(filename, "rb"); if (f == NULL) { - perror("fopen"); + fprintf(stderr, "fopen(%s): %m\n", filename); return; } @@ -117,10 +131,9 @@ void benchmark_op(struct thread_state *ts) pthread_mutex_unlock(&ts->lock); } else { /* Write */ - sprintf(filename, "t%d/%d/%d", ts->thread_num, n1, n2); FILE *f = fopen(filename, "wb"); if (f == NULL) { - perror("fopen"); + fprintf(stderr, "fopen(%s): %m\n", filename); return; } diff --git a/microbench/run2.sh b/microbench/run2.sh index d01a3a3..dd801c0 100755 --- a/microbench/run2.sh +++ b/microbench/run2.sh @@ -38,7 +38,7 @@ run_experiments() { for size in 128 512 1024 2048; do for filesize in 1024; do BENCH_FILESIZE=$(($filesize * 1024)) - BENCH_FILECOUNT=$(($size * 1024 / $filesize / $BENCH_THREADS)) + BENCH_FILECOUNT=$(($size * 1024 / $filesize)) PREFIX=$BLUESKY_TARGET-$BENCH_WRITERATIO-${size}M-${filesize}k $HOME/bin/s3-cleanup.py diff --git a/microbench/setup/prepare-benchmark b/microbench/setup/prepare-benchmark index 3d2e350..eb5c7d5 100755 --- a/microbench/setup/prepare-benchmark +++ b/microbench/setup/prepare-benchmark @@ -31,13 +31,11 @@ mount -t nfs -o vers=3,tcp,rw,soft,intr $SERVER:/export $MNTDIR pushd $MNTDIR >/dev/null -for t in $(seq 0 $(($BENCH_THREADS - 1))); do - for i in $(seq 0 $(($BENCH_FILECOUNT - 1))); do - n1=$(($i / $BENCH_DIRSIZE)) - n2=$(($i % $BENCH_DIRSIZE)) - mkdir -p t$t/$n1 - dd if=/dev/zero of=t$t/$n1/$n2 bs=$BENCH_FILESIZE count=1 - done +mkdir $(seq 0 $(($BENCH_FILECOUNT / $BENCH_DIRSIZE))) +for i in $(seq 0 $(($BENCH_FILECOUNT - 1))); do + n1=$(($i / $BENCH_DIRSIZE)) + n2=$(($i % $BENCH_DIRSIZE)) + dd if=/dev/zero of=$n1/$n2 bs=$BENCH_FILESIZE count=1 done find -type f -exec sha1sum '{}' \;