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;
}
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;
}
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
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 '{}' \;