Whamcloud - gitweb
LU-10997 build: add files to .gitignore
[fs/lustre-release.git] / lustre / tests / dom-performance.sh
1 #!/bin/bash
2 #
3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
5 #
6
7 set -e
8
9 ONLY=${ONLY:-"$*"}
10 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"$DOM_PERFORMANCE_EXCEPT"}
11 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
12
13 [ "$SLOW" = "no" ] && EXCEPT_SLOW=""
14
15 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
16
17 . $LUSTRE/tests/test-framework.sh
18
19 init_test_env $@
20 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
21 init_logging
22
23 SAVED_FAIL_ON_ERROR=$FAIL_ON_ERROR
24 FAIL_ON_ERROR=false
25
26 SAVED_DEBUG=$($LCTL get_param -n debug 2> /dev/null)
27
28 check_and_setup_lustre
29
30 build_test_filter
31
32 DP_DNE=${DP_DNE:-"no"}
33 DP_DIO=${DP_DIO:-"no"}
34
35 DOM_SIZE=${DOM_SIZE:-"1M"}
36 DP_OSC="mdc"
37
38 rm -rf $DIR/*
39
40 DP_NORM=$DIR/dp_norm
41 DP_DOM=$DIR/dp_dom
42 DP_STATS=${DP_STATS:-"no"}
43
44 # total number of files
45 DP_FNUM=${DP_FNUM:-16384}
46 # number of threads
47 DP_NUM=${DP_NUM:-4}
48
49 # 1 stripe for normal files
50 mkdir -p $DP_NORM
51 $LFS setstripe -c 1 $DP_NORM ||
52         error "Cannot create test directory for ordinary files"
53
54 if [ "x$DP_DNE" == "xyes" ] ; then
55         $LFS setdirstripe -i 0 -c 2 $DP_DOM ||
56                 error "Cannot create striped directory"
57 else
58         mkdir -p $DP_DOM
59 fi
60
61 $LFS setstripe -E ${DOM_SIZE} -L mdt -E EOF $DP_DOM ||
62         error "Cannot create test directory for dom files"
63
64 dp_clear_stats() {
65         local cli=$1
66
67         $LCTL set_param -n osc.*.stats=0
68         $LCTL set_param -n mdc.*.stats=0
69         $LCTL set_param -n ${cli}.*.${cli}_stats=0
70         $LCTL set_param -n ${cli}.*.rpc_stats=0
71         $LCTL set_param -n llite.*.read_ahead_stats=0
72         $LCTL set_param -n llite.*.unstable_stats=0
73 }
74
75 dp_collect_stats() {
76         local cli=$1
77
78         sync;sync
79         echo ----- MDC RPCs: $(calc_stats mdc.*.stats req_active)
80         echo ----- OSC RPCs: $(calc_stats osc.*.stats req_active)
81
82         if [ "x$DP_STATS" != "xyes" ] ; then
83                 return 0
84         fi
85
86         $LCTL get_param ${cli}.*.${cli}_stats
87         $LCTL get_param ${cli}.*.rpc_stats
88         # for OSC get both OSC and MDC stats
89         if [ $cli == "osc" ] ; then
90                 $LCTL get_param mdc.*.stats
91         fi
92         $LCTL get_param ${cli}.*.stats
93         $LCTL get_param ${cli}.*.unstable_stats
94         $LCTL get_param ${cli}.*.${cli}_cached_mb
95         $LCTL get_param llite.*.read_ahead_stats
96 }
97
98 dp_setup_test() {
99         local cli=$1
100
101         cancel_lru_locks $cli
102         ### drop all debug
103         $LCTL set_param -n debug=0
104         dp_clear_stats $cli
105 }
106
107 dp_run_cmd() {
108         local cmd=$1
109         local cmdlog=$TMP/dp_cmd.log
110         local rc
111
112         dp_setup_test $DP_OSC
113         if ! grep -qw "$MOUNT" /proc/mounts ; then
114                 echo "!!!!! Lustre is not mounted !!!!!, aborting"
115                 return 0
116         fi
117
118         echo "## $cmd" | awk '{ if (NR==1) {gsub(/[ \t\r\n]+/, " "); \
119                                 gsub(/\|.*$/, ""); print }}'
120         echo "## $(date +'%F %H:%M:%S'): START"
121         eval $cmd 2>&1 | tee $cmdlog || true
122
123         rc=${PIPESTATUS[0]}
124         if [ $rc -eq 0 ] && grep -q "p4_error:" $cmdlog ; then
125                 rc=1
126         fi
127
128         dp_collect_stats $DP_OSC
129         remount_client $DIR > /dev/null
130         return $rc
131 }
132
133 run_MDtest() {
134         if ! which mdtest > /dev/null 2>&1 ; then
135                 echo "Mdtest is not installed, skipping"
136                 return 0
137         fi
138
139         local mdtest=$(which mdtest)
140
141         local TDIR=${1:-$MOUNT}
142         local th_num=$((DP_FNUM * 2 / DP_NUM))
143         local bsizes="8192"
144
145         [ "$SLOW" = "yes" ] && bsizes="4096 16384"
146
147         for bsize in $bsizes ; do
148                 dp_run_cmd "mpirun -np $DP_NUM $mdtest -i 3 -I $th_num -F \
149                         -z 1 -b 1 -L -u -w $bsize -R -d $TDIR"
150                 if [ ${PIPESTATUS[0]} != 0 ]; then
151                         error "MDtest failed, aborting"
152                 fi
153         done
154
155         rm -rf $TDIR/*
156         return 0
157 }
158
159 run_SmallIO() {
160         if [ ! -f createmany ] ; then
161                 echo "Createmany is not installed, skipping"
162                 return 0
163         fi
164
165         if [ ! -f smalliomany ] ; then
166                 echo "Smalliomany is not installed, skipping"
167                 return 0
168         fi
169
170         local TDIR=${1:-$DIR}
171         local count=$DP_FNUM
172
173         local MIN=$((count * 16))
174         [ $MDSSIZE -le $MIN ] && count=$((MDSSIZE / 16))
175
176         dp_run_cmd "./createmany -o $TDIR/file- $count | grep 'total:'"
177         if [ ${PIPESTATUS[0]} != 0 ]; then
178                 error "File creation failed, aborting"
179         fi
180
181         if [ -f statmany ]; then
182                 dp_run_cmd "./statmany -s $TDIR/file- $count $((count * 5)) |
183                         grep 'total:'"
184                 if [ ${PIPESTATUS[0]} != 0 ]; then
185                         error "File stat failed, aborting"
186                 fi
187
188         fi
189
190         for opc in w a r ; do
191                 dp_run_cmd "./smalliomany -${opc} $TDIR/file- $count 300 |
192                         grep 'total:'"
193                 if [ ${PIPESTATUS[0]} != 0 ]; then
194                         error "SmallIO -${opc} failed, aborting"
195                 fi
196
197         done
198
199         dp_run_cmd "./unlinkmany $TDIR/file- $count | grep 'total:'"
200         if [ ${PIPESTATUS[0]} != 0 ]; then
201                 error "SmallIO failed, aborting"
202         fi
203
204         return 0
205 }
206
207 run_IOR() {
208         if ! which IOR > /dev/null 2>&1 ; then
209                 echo "IOR is not installed, skipping"
210                 return 0
211         fi
212
213         local IOR=$(which IOR)
214         local iter=$((DP_FNUM / DP_NUM))
215         local direct=""
216
217         if [ "x$DP_DIO" == "xyes" ] ; then
218                 direct="-B"
219         fi
220
221         local TDIR=${1:-$MOUNT}
222         local bsizes="8"
223         [ "$SLOW" = "yes" ] && bsizes="4 16"
224
225         for bsize in $bsizes ; do
226                 segments=$((128 / bsize))
227
228                 dp_run_cmd "mpirun -np $DP_NUM $IOR \
229                         -a POSIX -b ${bsize}K -t ${bsize}K -o $TDIR/ -k \
230                         -s $segments -w -r -i $iter -F -E -z -m -Z $direct"
231                 if [ ${PIPESTATUS[0]} != 0 ]; then
232                         error "IOR write test for ${bsize}K failed, aborting"
233                 fi
234
235                 # check READ performance only (no cache)
236                 dp_run_cmd "mpirun -np $DP_NUM $IOR \
237                         -a POSIX -b ${bsize}K -t ${bsize}K -o $TDIR/ -X 42\
238                         -s $segments -r -i $iter -F -E -z -m -Z $direct"
239                 if [ ${PIPESTATUS[0]} != 0 ]; then
240                         error "IOR read test for ${bsize}K failed, aborting"
241                 fi
242
243         done
244         rm -rf $TDIR/*
245         return 0
246 }
247
248 run_Dbench() {
249         if ! which dbench > /dev/null 2>&1 ; then
250                 echo "Dbench is not installed, skipping"
251                 return 0
252         fi
253
254         if [ "x$DP_DNE" == "xyes" ] ; then
255                 echo "dbench uses subdirs, skipping for DNE setup"
256                 return 0
257         fi
258
259         local TDIR=${1:-$MOUNT}
260
261         dp_run_cmd "dbench -D $TDIR $DP_NUM | egrep -v 'warmup|execute'"
262         if [ ${PIPESTATUS[0]} != 0 ]; then
263                 error "Dbench failed, aborting"
264         fi
265
266         rm -rf $TDIR/*
267         return 0
268 }
269
270 run_FIO() {
271         # https://github.com/axboe/fio/archive/fio-2.8.zip
272         if ! which fio > /dev/null 2>&1 ; then
273                 echo "No FIO installed, skipping"
274                 return 0
275         fi
276
277         local fnum=128 # per thread
278         local total=$((fnum * DP_NUM)) # files in all threads
279         local loops=$((DP_FNUM / total)) # number of loops
280         local direct=""
281         local output=""
282
283         if [ $loops -eq 0 ] ; then
284                 loops=1
285         fi
286
287         if [ "x$DP_DIO" == "xyes" ] ; then
288                 direct="--direct=1"
289         else
290                 direct="--buffered=1 --bs_unaligned=1"
291         fi
292
293         if [ "x$DP_STATS" != "xyes" ] ; then
294                 output="--minimal"
295         fi
296
297         local TDIR=${1:-$MOUNT}
298         base_cmd="fio --name=smallio --ioengine=posixaio $output \
299                   --iodepth=$((DP_NUM * 4)) --directory=$TDIR \
300                   --nrfiles=$fnum --openfiles=10000 \
301                   --numjobs=$DP_NUM --filesize=64k --lockfile=readwrite"
302
303         dp_run_cmd "$base_cmd --create_only=1" > /dev/null
304         if [ ${PIPESTATUS[0]} != 0 ]; then
305                 error "FIO file creation failed, aborting"
306         fi
307
308         local bsizes="8"
309         [ "$SLOW" = "yes" ] && bsizes="4 16"
310
311         for bsize in $bsizes ; do
312                 dp_run_cmd "$base_cmd --bs=${bsize}k --rw=randwrite $direct \
313                          --file_service_type=random --randrepeat=1 \
314                          --norandommap --group_reporting=1 --loops=$loops |
315                         awk -F\; '{printf \"WRITE: BW %dKiB/sec, IOPS %d, \
316                                         lat (%d/%d/%d)usec\n\",\
317                                         \$48, \$49, \$53, \$57, \$81}'"
318                 if [ ${PIPESTATUS[0]} != 0 ]; then
319                         error "FIO write test with ${bsize}k failed, aborting"
320                 fi
321
322                 dp_run_cmd "$base_cmd --bs=${bsize}k --rw=randread $direct \
323                          --file_service_type=random --randrepeat=1 \
324                          --norandommap --group_reporting=1 --loops=$loops |
325                         awk -F\; '{printf \"READ : BW %dKiB/sec, IOPS %d, \
326                                         lat (%d/%d/%d)usec\n\",\
327                                         \$7, \$8, \$12, \$16, \$40}'"
328                 if [ ${PIPESTATUS[0]} != 0 ]; then
329                         error "FIO read test with ${bsize}k failed, aborting"
330                 fi
331         done
332         rm -rf $TDIR/*
333         return 0
334 }
335
336 dp_test_run() {
337         local test=$1
338         local facets=$(get_facets MDS)
339         local nodes=$(comma_list $(mdts_nodes))
340         local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
341
342         save_lustre_params $facets "mdt.*.dom_lock" >> $p
343
344         printf "\n##### $test: DoM files, IO lock on open\n"
345         do_nodes $nodes "lctl set_param -n mdt.*.dom_lock=1"
346         DP_OSC="mdc"
347         run_${test} $DP_DOM
348
349         printf "\n##### $test: DoM files, no IO lock on open\n"
350         do_nodes $nodes "lctl set_param -n mdt.*.dom_lock=0"
351         DP_OSC="mdc"
352         run_${test} $DP_DOM
353
354         printf "\n##### $test: OST files\n"
355         DP_OSC="osc"
356         run_${test} $DP_NORM
357
358         restore_lustre_params < $p
359 }
360
361 test_smallio() {
362         dp_test_run SmallIO
363 }
364 run_test smallio "Performance comparision: smallio"
365
366 test_mdtest() {
367         dp_test_run MDtest
368 }
369 run_test mdtest "Performance comparision: mdtest"
370
371 test_IOR() {
372         dp_test_run IOR
373 }
374 run_test IOR "Performance comparision: IOR"
375
376 test_dbench() {
377         dp_test_run Dbench
378 }
379 run_test dbench "Performance comparision: dbench"
380
381 test_fio() {
382         dp_test_run FIO
383 }
384 run_test fio "Performance comparision: FIO"
385
386 FAIL_ON_ERROR=$SAVED_FAIL_ON_ERROR
387 $LCTL set_param -n debug="$SAVED_DEBUG"
388
389 complete $SECONDS
390 check_and_cleanup_lustre
391 exit_status