summaryrefslogtreecommitdiffstats
path: root/fsbench.sh
blob: a76126be8ce40f2c6f4a17933608ddc813a38f5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
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