Whamcloud - gitweb
bf5085efc43118ce1017a5462a55d794cc1fcd91
[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
29 . $LUSTRE/tests/functions.sh
30 build_test_filter
31 check_and_setup_lustre
32
33 # if MACHINEFILE set and exists -- use it
34 MACHINEFILE=${MACHINEFILE:-$TMP/$(basename $0 .sh)-$(hostname).machines}
35 clients=${CLIENTS:-$HOSTNAME}
36 generate_machine_file $clients $MACHINEFILE ||
37         error "Failed to generate machine file"
38
39 DP_DIO=${DP_DIO:-"no"}
40
41 DOM_SIZE=${DOM_SIZE:-"1M"}
42 DP_OSC="mdc"
43
44 DP_NORM=$DIR/dp_norm
45 DP_DOM=$DIR/dp_dom
46 DP_DOM_DNE=$DIR/dp_dne
47 DP_STATS=${DP_STATS:-"no"}
48
49 if $DO_CLEANUP; then
50         rm -rf $DIR/*
51 else
52         rm -rf $DP_NORM $DP_DOM $DP_DOM_DNE
53 fi
54
55 # total number of files
56 DP_FNUM=${DP_FNUM:-16384}
57 # number of threads
58 DP_NUM=${DP_NUM:-4}
59
60 # 1 stripe for normal files
61 mkdir -p $DP_NORM
62 $LFS setstripe -c 2 $DP_NORM ||
63         error "Cannot create test directory for ordinary files"
64
65 if [[ $MDSCOUNT -gt 1 ]] ; then
66         $LFS setdirstripe -i 0 -c $MDSCOUNT $DP_DOM_DNE ||
67                 error_noexit "Cannot create striped directory"
68         $LFS setstripe -E ${DOM_SIZE} -L mdt -E EOF $DP_DOM_DNE ||
69                 error_noexit "Cannot create test directory for dom files"
70 fi
71
72 mkdir -p $DP_DOM
73 $LFS setstripe -E ${DOM_SIZE} -L mdt -E EOF $DP_DOM ||
74         error "Cannot create test directory for dom files"
75
76 dp_clear_stats() {
77         local cli=$1
78
79         $LCTL set_param -n osc.*.stats=0
80         $LCTL set_param -n mdc.*.stats=0
81         $LCTL set_param -n ${cli}.*.${cli}_stats=0
82         $LCTL set_param -n ${cli}.*.rpc_stats=0
83         $LCTL set_param -n llite.*.read_ahead_stats=0
84         $LCTL set_param -n llite.*.unstable_stats=0
85 }
86
87 dp_collect_stats() {
88         local cli=$1
89
90         sync;sync
91         echo ----- MDC RPCs: $(calc_stats mdc.*.stats req_active)
92         echo ----- OSC RPCs: $(calc_stats osc.*.stats req_active)
93
94         if [ "x$DP_STATS" != "xyes" ] ; then
95                 return 0
96         fi
97
98         $LCTL get_param ${cli}.*.${cli}_stats
99         $LCTL get_param ${cli}.*.rpc_stats
100         # for OSC get both OSC and MDC stats
101         if [ $cli == "osc" ] ; then
102                 $LCTL get_param mdc.*.stats
103         fi
104         $LCTL get_param ${cli}.*.stats
105         $LCTL get_param ${cli}.*.unstable_stats
106         $LCTL get_param ${cli}.*.${cli}_cached_mb
107         $LCTL get_param llite.*.read_ahead_stats
108 }
109
110 dp_setup_test() {
111         local cli=$1
112
113         cancel_lru_locks $cli
114         ### drop all debug except critical
115         $LCTL set_param -n debug="error warning console emerg"
116         dp_clear_stats $cli
117 }
118
119 dp_run_cmd() {
120         local cmd=$1
121         local cmdlog=$TMP/dp_cmd.log
122         local rc
123
124         dp_setup_test $DP_OSC
125         if ! grep -qw "$MOUNT" /proc/mounts ; then
126                 echo "!!!!! Lustre is not mounted !!!!!, aborting"
127                 return 0
128         fi
129
130         echo "## $cmd" | awk '{ if (NR==1) {gsub(/[ \t\r\n]+/, " "); \
131                                 gsub(/\|.*$/, ""); print }}'
132         echo "## $(date +'%F %H:%M:%S'): START"
133         eval $cmd 2>&1 | tee $cmdlog || true
134
135         rc=${PIPESTATUS[0]}
136         if [ $rc -eq 0 ] && grep -q "p4_error:" $cmdlog ; then
137                 rc=1
138         fi
139
140         dp_collect_stats $DP_OSC
141         remount_client $DIR > /dev/null
142         return $rc
143 }
144
145 run_MDtest() {
146         if ! which mdtest > /dev/null 2>&1 ; then
147                 skip_env "Mdtest is not installed, skipping"
148         fi
149
150         local mdtest=$(which mdtest)
151
152         local TDIR=${1:-$MOUNT}
153         local th_num=$((DP_FNUM * 2 / DP_NUM))
154         local bsizes="8192"
155
156         chmod 0777 $TDIR
157
158         [ "$SLOW" = "yes" ] && bsizes="4096 32768"
159
160         for bsize in $bsizes ; do
161                 dp_run_cmd "mpi_run -np $DP_NUM $mdtest -i 3 -I $th_num -F \
162                         -z 1 -b 1 -L -u -w $bsize -R -d $TDIR"
163                 if [ ${PIPESTATUS[0]} != 0 ]; then
164                         error "MDtest failed, aborting"
165                 fi
166         done
167
168         rm -rf $TDIR/*
169         return 0
170 }
171
172 run_SmallIO() {
173         local TDIR=${1:-$DIR}
174         local count=$DP_FNUM
175
176         local MIN=$((count * 16))
177         local mdssize=$(mdssize_from_index $TDIR 0)
178         [ $mdssize -le $MIN ] && count=$((mdssize / 16))
179
180         dp_run_cmd "createmany -o $TDIR/file- $count | grep 'total:'"
181         if [ ${PIPESTATUS[0]} != 0 ]; then
182                 error "File creation failed, aborting"
183         fi
184
185         dp_run_cmd "statmany -s $TDIR/file- $count $((count * 5)) |
186                 grep 'total:'"
187         if [ ${PIPESTATUS[0]} != 0 ]; then
188                 error "File stat failed, aborting"
189         fi
190
191         for opc in w a r ; do
192                 dp_run_cmd "smalliomany -${opc} $TDIR/file- $count 300 |
193                         grep 'total:'"
194                 if [ ${PIPESTATUS[0]} != 0 ]; then
195                         error "SmallIO -${opc} failed, aborting"
196                 fi
197
198         done
199
200         dp_run_cmd "unlinkmany $TDIR/file- $count | grep 'total:'"
201         if [ ${PIPESTATUS[0]} != 0 ]; then
202                 error "SmallIO failed, aborting"
203         fi
204
205         return 0
206 }
207
208 run_IOR() {
209         if ! which IOR > /dev/null 2>&1 ; then
210                 skip_env "IOR is not installed, skipping"
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
223         chmod 0777 $TDIR
224
225         # for DoM large files (beyond the DoM size) use
226         # DOM_SIZE=1M :
227         #     bsize="4096 " - 4Mb
228         #     nsegments=$((128 * 1024))
229         # DOM_SIZE=64k :
230         #     bsize="1024 " - 1Mb
231         #     nsegments=$((32 * 1024))
232         local bsizes=${BSIZES:-"4 32"}
233         local nsegments=${NSEGMENTS:-128}
234         [ "$SLOW" = "no" ] && bsizes="8"
235
236         for bsize in $bsizes ; do
237                 segments=$((nsegments / bsize))
238
239                 dp_run_cmd "mpi_run -np $DP_NUM $IOR \
240                         -a POSIX -b ${bsize}K -t ${bsize}K -o $TDIR/ -k \
241                         -s $segments -w -r -i $iter -F -E -z -m -Z $direct" |
242                         awk '($1 !~ /^(write|read|access)$/) || NF>12 {print}'
243                 if [ ${PIPESTATUS[0]} != 0 ]; then
244                         error "IOR write test for ${bsize}K failed, aborting"
245                 fi
246
247                 # check READ performance only (no cache)
248                 dp_run_cmd "mpi_run -np $DP_NUM $IOR \
249                         -a POSIX -b ${bsize}K -t ${bsize}K -o $TDIR/ -X 42\
250                         -s $segments -r -i $iter -F -E -z -m -Z $direct" |
251                         awk '($1 !~ /^(read|access|remove)$/) || NF>12 {print}'
252                 if [ ${PIPESTATUS[0]} != 0 ]; then
253                         error "IOR read test for ${bsize}K failed, aborting"
254                 fi
255
256         done
257         rm -rf $TDIR/*
258         return 0
259 }
260
261 run_Dbench() {
262         if ! which dbench > /dev/null 2>&1 ; then
263                 skip_env "Dbench is not installed, skipping"
264         fi
265
266         local TDIR=${1:-$MOUNT}
267
268         if [ "x$DP_DOM_DNE" == "x$TDIR" ] ; then
269                 echo "dbench uses subdirs, skipping for DNE dir"
270                 return 0
271         fi
272
273         dp_run_cmd "dbench -D $TDIR $DP_NUM | egrep -v 'warmup|execute'"
274         if [ ${PIPESTATUS[0]} != 0 ]; then
275                 error "Dbench failed, aborting"
276         fi
277
278         rm -rf $TDIR/*
279         return 0
280 }
281
282 run_FIO() {
283         # https://github.com/axboe/fio/archive/fio-2.8.zip
284         if ! which fio > /dev/null 2>&1 ; then
285                 skip_env "No FIO installed, skipping"
286         fi
287
288         local fnum=128 # per thread
289         local total=$((fnum * DP_NUM)) # files in all threads
290         local loops=$((DP_FNUM / total)) # number of loops
291         local direct=""
292         local output=""
293
294         if [ $loops -eq 0 ] ; then
295                 loops=1
296         fi
297
298         if [ "x$DP_DIO" == "xyes" ] ; then
299                 direct="--direct=1"
300         else
301                 direct="--buffered=1 --bs_unaligned=1"
302         fi
303
304         if [ "x$DP_STATS" != "xyes" ] ; then
305                 output="--minimal"
306         fi
307
308         local TDIR=${1:-$MOUNT}
309         base_cmd="fio --name=smallio --ioengine=posixaio $output \
310                   --iodepth=$((DP_NUM * 4)) --directory=$TDIR \
311                   --nrfiles=$fnum --openfiles=10000 \
312                   --numjobs=$DP_NUM --filesize=64k --lockfile=readwrite"
313
314         dp_run_cmd "$base_cmd --create_only=1" > /dev/null
315         if [ ${PIPESTATUS[0]} != 0 ]; then
316                 error "FIO file creation failed, aborting"
317         fi
318
319         local bsizes="8"
320         [ "$SLOW" = "yes" ] && bsizes="4 32"
321
322         for bsize in $bsizes ; do
323                 local write_cmd="$base_cmd --bs=${bsize}k --rw=randwrite \
324                         $direct --file_service_type=random --randrepeat=1 \
325                          --norandommap --group_reporting=1 --loops=$loops"
326                 if [ "x$DP_STATS" != "xyes" ] ; then
327                         dp_run_cmd "$write_cmd | awk -F\; '{printf \"WRITE: \
328                                 BW %dKiB/sec, IOPS %d, lat (%d/%d/%d)usec\n\", \
329                                 \$48, \$49, \$53, \$57, \$81}'"
330                 else
331                         dp_run_cmd "$write_cmd"
332                 fi
333                 if [ ${PIPESTATUS[0]} != 0 ]; then
334                         error "FIO write test with ${bsize}k failed, aborting"
335                 fi
336
337                 local read_cmd="$base_cmd --bs=${bsize}k --rw=randread \
338                         $direct --file_service_type=random --randrepeat=1 \
339                          --norandommap --group_reporting=1 --loops=$loops"
340                 if [ "x$DP_STATS" != "xyes" ] ; then
341                         dp_run_cmd "$read_cmd | awk -F\; '{printf \"READ : \
342                                 BW %dKiB/sec, IOPS %d, lat (%d/%d/%d)usec\n\", \
343                                 \$7, \$8, \$12, \$16, \$40}'"
344                 else
345                         dp_run_cmd "$read_cmd"
346                 fi
347                 if [ ${PIPESTATUS[0]} != 0 ]; then
348                         error "FIO read test with ${bsize}k failed, aborting"
349                 fi
350         done
351         rm -rf $TDIR/*
352         return 0
353 }
354
355 run_compbench() {
356         local compilebench
357         if [ x$cbench_DIR = x ]; then
358                 compilebench=$(which compilebench 2> /dev/null)
359         else
360                 cd $cbench_DIR
361                 [ -x compilebench ] ||
362                         skip_env "compilebench is missing in $cbench_DIR"
363                 compilebench=compilebench
364         fi
365
366         [ x$compilebench != x ] ||
367                 skip_env "Compilebench is not installed, skipping"
368
369         local TDIR=${1:-$MOUNT}
370
371         dp_run_cmd "$compilebench -D $TDIR -i 2 -r 2 --makej"
372         if [ ${PIPESTATUS[0]} != 0 ]; then
373                 error "Compilebench failed, aborting"
374         fi
375
376         rm -rf $TDIR/*
377 }
378
379 dp_test_run() {
380         local test=$1
381         local facets=$(get_facets MDS)
382         local nodes=$(comma_list $(mdts_nodes))
383         local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
384
385         save_lustre_params $facets "mdt.*.dom_lock" >> $p
386
387         printf "\n##### $test: DoM files\n"
388         do_nodes $nodes "lctl set_param -n mdt.*.dom_lock=1"
389         DP_OSC="mdc"
390         run_${test} $DP_DOM
391
392         if [ -d $DP_DOM_DNE ] ; then
393                 printf "\n##### $test: DoM files + DNE\n"
394                 DP_OSC="mdc"
395                 run_${test} $DP_DOM_DNE
396         fi
397
398         printf "\n##### $test: OST files\n"
399         DP_OSC="osc"
400         run_${test} $DP_NORM
401
402         restore_lustre_params < $p
403         rm -f $p
404 }
405
406 test_smallio() {
407         dp_test_run SmallIO
408 }
409 run_test smallio "Performance comparision: smallio"
410
411 test_mdtest() {
412         dp_test_run MDtest
413 }
414 run_test mdtest "Performance comparision: mdtest"
415
416 test_IOR() {
417         dp_test_run IOR
418 }
419 run_test IOR "Performance comparision: IOR"
420
421 test_dbench() {
422         dp_test_run Dbench
423 }
424 run_test dbench "Performance comparision: dbench"
425
426 test_fio() {
427         dp_test_run FIO
428 }
429 run_test fio "Performance comparision: FIO"
430
431 test_compbench() {
432         dp_test_run compbench
433 }
434 run_test compbench "Performance comparision: compilebench"
435
436 FAIL_ON_ERROR=$SAVED_FAIL_ON_ERROR
437 $LCTL set_param -n debug="$SAVED_DEBUG"
438
439 complete $SECONDS
440 check_and_cleanup_lustre
441 exit_status