summaryrefslogtreecommitdiffstats
path: root/fsbench.sh
diff options
context:
space:
mode:
Diffstat (limited to 'fsbench.sh')
-rwxr-xr-xfsbench.sh161
1 files changed, 161 insertions, 0 deletions
diff --git a/fsbench.sh b/fsbench.sh
new file mode 100755
index 0000000..a76126b
--- /dev/null
+++ b/fsbench.sh
@@ -0,0 +1,161 @@
+#! /bin/bash
+
+DEVICE="/dev/md1"
+WIDTH=32
+CHUNK=64
+FILE_SIZE=128 #1024
+FAST_SPEED=3650
+NUMA_CPU=4
+PYHST="/root/pyhst/pyhst.sh"
+PYHST_DATA="/home/csa/data/bench"
+
+FS_LIST="ext4 xfs ext2 jfs reiserfs btrfs"
+
+
+
+END_START=`expr $WIDTH '*' 2 - 2`
+END_END=`expr $WIDTH '*' 2`
+
+echo $DEVICE | grep "/dev/md" &> /dev/null
+if [ $? -eq 0 ]; then SUFFIX="p"; else SUFFIX=""; fi
+
+
+umount -l /mnt/slow &> /dev/null
+umount -l /mnt/fast &> /dev/null
+
+function partition {
+ parted $DEVICE --script mklabel gpt
+ parted $DEVICE --script rm 3 &> /dev/null
+ parted $DEVICE --script rm 2 &> /dev/null
+ parted $DEVICE --script rm 1 &> /dev/null
+ parted $DEVICE --script mkpart primary 1GB 2TB
+ parted $DEVICE --script mkpart primary ${END_START}TB ${END_END}TB
+ parted $DEVICE --script mkpart primary 2TB 3TB
+}
+
+function format_ext4 {
+ block=4 # in KB (4096)
+ stride=`expr $CHUNK / $block`
+ swidth=`expr $stride '*' $WIDTH`
+ mkfs.ext4 -b 4096 -E stride=${stride},stripe-width=${swidth} $1 > /dev/null
+ return 0
+}
+
+function format_ext2 {
+ block=4 # in KB (4096)
+ stride=`expr $CHUNK / $block`
+ swidth=`expr $stride '*' $WIDTH`
+ mkfs.ext2 -b 4096 -E stride=${stride},stripe-width=${swidth} $1 > /dev/null
+ return 0
+}
+
+function format_xfs {
+ mkfs.xfs -f -d su=${CHUNK}k,sw=${WIDTH} $1 > /dev/null
+ mount -o noatime,allocsize=1GiB,largeio,swalloc $1 $2
+ return 1
+}
+
+function format_xfsrt {
+ mkfs.xfs -f -d su=${CHUNK}k,sw=${WIDTH} -r rtdev=$1,extsize=1g ${DEVICE}${SUFFIX}3 > /dev/null
+ mount -o noatime,allocsize=1GiB,largeio,swalloc,rtdev=$1 ${DEVICE}${SUFFIX}3 $2
+ return 1
+}
+
+function format_btrfs {
+ sector=`expr $CHUNK '*' 1024`
+# mkfs.btrfs -s $sector -l $sector -n $sector $1 > /dev/null
+ mkfs.btrfs $1 > /dev/null
+ return 0
+}
+
+function format_jfs {
+ mkfs.jfs -q $1 > /dev/null
+ return 0
+}
+
+function format_reiserfs {
+ mkfs.reiserfs -q $1 > /dev/null
+ return 0
+}
+
+function bench_path {
+ speed=$2
+ res=`stdbuf -oL -eL ./fwbench.sh $1/testfile ${FILE_SIZE} $speed |tee /dev/stderr | tail -n 7 | sed -e ':a;N;$!ba;s/\n/@eol@/g'`
+ echo $res | sed -e 's/@eol@/\n/g'
+ res=`echo $res | sed -e 's/@eol@/\n/g' | tail -n 1 | cut -d ':' -f 2`
+ if [ $res -gt 0 ]; then
+ speed=$res
+ fi
+ stdbuf -oL -eL taskset -c $NUMA_CPU ./seqreader $1 | tee /dev/stderr | tail -n 5
+}
+
+function bench_device {
+ speed=$2
+ res=`stdbuf -oL -eL ./fwbench.sh $1 ${FILE_SIZE} $speed |tee /dev/stderr | tail -n 7 | sed -e ':a;N;$!ba;s/\n/@eol@/g'`
+ echo $res | sed -e 's/@eol@/\n/g'
+ res=`echo $res | sed -e 's/@eol@/\n/g' | tail -n 1 | cut -d ':' -f 2`
+ if [ $res -gt 0 ]; then
+ speed=$res
+ fi
+ stdbuf -oL -eL taskset -c $NUMA_CPU ./seqreader $1 ${FILE_SIZE} | tee /dev/stderr | tail -n 5
+}
+
+
+function bench_pyhst {
+ data=$1/pyhst
+ mkdir -p $data
+ cat $PYHST_DATA/*.par | sed -e "s|@PATH@|$data|g" > $data/bench.par
+ cp -r $PYHST_DATA/out_phase $data/
+ echo 3 > /proc/sys/vm/drop_caches
+ eval stdbuf -oL -eL $PYHST $data/bench.par 2>&1 | tee /dev/stderr | grep "Input/Output"
+}
+
+function test_fs {
+ speed=`expr $FAST_SPEED + 50`
+ formater="format_$1"
+ eval $formater ${DEVICE}${SUFFIX}1 /mnt/fast
+ if [ $? -eq 0 ]; then
+ mount -o noatime ${DEVICE}${SUFFIX}1 /mnt/fast
+ fi
+ echo "Testing $1 (fast partition)"
+ echo "=================================="
+ bench_path /mnt/fast $speed
+
+ echo
+ echo "Testing $1 (PyHST)"
+ echo "=================================="
+ bench_pyhst /mnt/fast
+
+ umount /mnt/fast
+
+ echo
+
+ eval $formater ${DEVICE}${SUFFIX}2 /mnt/slow
+ if [ $? -eq 0 ]; then
+ mount -o noatime ${DEVICE}${SUFFIX}2 /mnt/slow
+ fi
+ echo "Testing $1 (slow partition)"
+ echo "=================================="
+ bench_path /mnt/slow $speed
+ umount /mnt/slow
+
+ echo
+ echo
+}
+
+function test_partition {
+ speed=`expr $FAST_SPEED + 50`
+ echo "Testing partition: $1"
+ echo "=================================="
+ bench_device $1 $speed
+ echo
+}
+
+partition
+test_partition ${DEVICE}
+test_partition ${DEVICE}${SUFFIX}2
+
+for fs in $FS_LIST; do
+ test_fs $fs
+done
+