123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161 |
- #! /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
|