3 ######################################################################
6 # the SCSI devices to measure
7 scsidevs="/dev/sde /dev/sdh"
10 # NB ensure the path exists if it includes subdirs
13 # what to do (read or write)
16 # total size per device (MBytes)
17 # NB bigger than device cache is good
20 # record size (KBytes)
24 # Concurrent regions per device
28 # threads to share between concurrent regions per device
29 # NB survey skips over #thr < #regions and #thr > SG_MAX_QUEUE
33 #####################################################################
35 # disk block size (Bytes)
38 # max # threads per individual sgp_dd instance
43 for d in $scsidevs; do
44 devs[$i]=`sg_map | awk "{if ($ 2 == \"$d\") print $ 1}"`
45 if [ -z "$devs[$i]" ]; then
46 echo "Can't find SG device for $d"
54 rsltf=${rslt}_${start}.summary
56 workf=${rslt}_${start}.detail
58 tmpf=${rslt}_${start}.tmp
61 if [ "$1" = "-n" ]; then
66 echo $minusn "$*" >> $rsltf
70 for ((rsz=$rszlo;rsz<=$rszhi;rsz*=2)); do
71 for ((crg=$crglo;crg<=$crghi;crg*=2)); do
72 for ((thr=$thrlo;thr<=$thrhi;thr*=2)); do
73 if ((thr < crg || thr/crg > SG_MAX_QUEUE)); then
78 blocks=$((size*((1024*1024)/bs)/crg))
80 # show computed parameters
81 actual_rsz=$((bpt*bs/1024))
82 actual_size=$((bs*count*crg/1024))
83 str=`printf 'total_size %8dK rsz %4d crg %5d thr %3d ' \
84 $((actual_size*ndevs)) $actual_rsz $((crg*ndevs)) $((thr*ndevs))`
85 echo "==============> $str" >> $workf
86 print_summary -n "$str"
87 freemem=`awk < /proc/meminfo '/^MemTotal:/ {printf "%d\n", $2}'`
88 if (((actual_rsz*thr/crg + 64)*crg*ndevs > freemem)); then
89 print_summary "ENOMEM"
92 for action in $actions; do
93 print_summary -n "$action "
94 echo "=====> $action" >> $workf
97 for ((i=0;i<ndevs;i++)); do
99 if [ $action = read ]; then
108 for ((j=0;j<crg;j++)); do
109 sgp_dd 2> ${tmpf}_${i}_${j} \
110 $inf $outf ${skip}=$((1024+j*blocks)) \
111 thr=$((thr/crg)) count=$count bs=$bs bpt=$bpt time=1&
116 # collect all results in 1 file
119 for ((i=0;i<ndevs;i++)); do
120 for ((j=0;j<crg;j++)); do
121 rtmp=${tmpf}_${i}_${j}
122 if grep 'time to transfer data' $rtmp > /dev/null 2>&1; then
126 cat ${rtmp} >> $workf
130 if ((ok != ndevs*crg)); then
131 print_summary -n "$((ndevs*crg - ok)) failed "
133 # compute MB/sec from elapsed
134 bw=`awk "BEGIN {printf \"%7.2f MB/s\", $actual_size * $ndevs / (( $t1 - $t0 ) * 1024); exit}"`
135 # compute MB/sec from nregions*slowest
137 '/time to transfer data/ {mb=$8/1.048576; if (n == 0 || mb < min) min = mb; n++}\
138 END {printf "%3d x %6.2f = %7.2f MB/s", n, min, min * n}'`
139 print_summary -n "$bw $check "