• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# this is retained mostly for historical purposes and may not be
2# up to date for contemporary netperf versions
3#
4# a script that can be used to measure aggregate netperf performance,
5# original author is Mike Traynor. Modifications to create the
6# "netperf TCP_ARR test" by rick jones
7#
8
9init_parms() {
10  TEST_TIME=60
11  NTEST=3
12  TOLERANCE=15
13  MAX_RETRIES=3
14
15  NETPERF="/usr/local/netperf/netperf"
16  NETPERF="./netperf"
17
18  NPROC_LIST=""
19  RR_SIZES=""
20  REM_HOST_LIST=""
21  DEVFILELIST=""
22  LLA=0
23  TCP=1
24  UDP=0
25  GPROF=0
26}
27
28set_default_parms() {
29  if [ "X$NPROC_LIST" = "X" ]
30  then
31    NPROC_LIST="1"
32  fi
33
34  if [ "X$REM_HOST_LIST" = "X" ]
35  then
36    REM_HOST_LIST="127.0.0.1"
37  fi
38
39  if [ "X$RR_SIZES" = "X" ]
40  then
41    RR_SIZES="1,1"
42  fi
43
44  NHOSTS=`echo $REM_HOST_LIST | awk '{printf "%d",NF}'`
45  GPROF_RUN_TIME=`expr $TEST_TIME - 20`
46}
47
48usage() {
49more << @EOF
50
51$*
52
53    USAGE: scale_script {test_options} {hostlist}
54
55    Measure maximum system network throughput.
56
57    The following are optional parameters:
58
59        -t nsec		: Causes each test to be run for nsec seconds.
60        -gprof system	: Take a gprof sample during the test.  system
61                  	  is the name of the kernel the system was booted
62                  	  with.
63        -n "nproclist"	: One series of tests is run for each space-separated
64                  	  value in nproclist.
65        -r "sizelist"	: One series of tests is run for each space-separated
66                	  request,reply pair in sizelist.
67	hostlist	: A space separated list of hosts to test against.
68
69        +|-tcp		: Run/Don't run TCP tests.
70        +|-udp		: Run/Don't run UDP tests.
71        +|-lla 		: Run/Don't run LLA tests; this option also requires
72			  the user to specify a list of network device files
73        	    	  using the -d option described below.
74
75    The following option must be provided when using the -lla option
76    described above:
77
78        -d "devfilelst" : Where devfilelst is a space-separated list
79                     	  of network device file pairs.  Each pair in
80                  	  the list contains two device file names,
81              	  	  separated by a comma (eg. /dev/lan0,/dev/lan1),
82                 	  where the device file on the left side of the
83                	  comma is for the local system and the device
84                	  file on the right side is for the remote system.
85                 	  A device file pair must be specified for each
86                   	  remote host which is specified.
87
88    Examples:
89
90        scale_script -n "8 16" -udp LGs37U1 LGs37U2 -r "1,1 100,100"
91
92        scale_script -t 1000 -n "16" -tcp -gprof /stand/vmunix LGs37U1 LGs37U2
93
94        scale_script -n 4 -lla -d /dev/lan0,/dev/lan0 /dev/lan1,/dev/lan0 \\
95          LGs37U1 LGs37U2
96
97@EOF
98}
99
100check_usage() {
101  if [ `expr $TCP + $UDP + $LLA` -eq 0 ]
102  then
103    usage $0: ERROR: Must specify a test
104    exit
105  fi
106
107  if [ $LLA -eq 1 ]
108  then
109    NDEV=`echo $DEVFILELIST | awk '{printf "%d",NF}'`
110    if [ $NDEV -ne $NHOSTS ]
111    then
112      usage $0: ERROR: Number of device files does not match number of hosts
113      exit
114    fi
115  fi
116
117  for HOST in $REM_HOST_LIST
118  do
119    if [ `/etc/ping $HOST 100 1 | awk '/transmitted/{print $4}'`0 -ne 10 ]
120    then
121      usage $0: ERROR: Cannot ping host: $HOST
122      exit
123    fi
124  done
125
126  if [ $GPROF -eq 1 ]
127  then
128    if [ ! -r $GPROF_KERNEL ]
129    then
130      usage $0: ERROR: Cannot find system file: $GPROF_KERNEL
131      exit
132    fi
133    if [ $GPROF_RUN_TIME -le 800 ]
134    then
135      echo "\nWARNING: GPROF RUN TIME LESS THAN 800 SECONDS\n"
136    fi
137  fi
138}
139
140display_headstone() {
141cat << @EOF
142
143$TESTNAME Aggregate REQUEST/RESPONSE TEST to $REM_HOST_LIST
144Local /Remote
145Socket Size   Request  Resp.   Elapsed  Trans.     Num.
146Send   Recv   Size     Size    Time     Rate       Concurrent
147bytes  Bytes  bytes    bytes   secs.    per sec    Netperfs
148
149@EOF
150}
151
152display_test_banner() {
153cat << @EOF
154@EOF
155}
156
157build_sap_list() {
158      LSAP=4
159      SAPLIST=""
160      PROC=0
161      while [ $PROC -lt $NPROCS ]
162      do
163        PROC=`expr $PROC + 1`
164        LSAP=`expr $LSAP + 4`
165        RSAP=`expr $LSAP + 2`
166        SAPLIST="$SAPLIST $LSAP,$RSAP"
167      done
168}
169
170start_gprof() {
171  if [ $GPROF -eq 1 ]
172  then
173    ( kgmon -h; kgmon -r; sleep 10; kgmon -b; sleep $GPROF_RUN_TIME; kgmon -h; kgmon -p $GPROF_KERNEL; mv gmon.out gmon.out.$TEST.$NPROCS )&
174  fi
175}
176
177start_1_proc_per_host() {
178  HOSTNUM=0
179  for HOST in $REM_HOST_LIST
180  do
181    if [ "$TEST" = "HIPPI_RR" ]
182    then
183      PROCNUM=`expr $PROCNUM + 1`
184      SAP=`echo $SAPLIST | awk "{print \\$$PROCNUM}"`
185      SAP="-s $SAP"
186      HOSTNUM=`expr $HOSTNUM + 1`
187      DEVFILE=`echo $DEVFILELIST | awk "{print \\$$HOSTNUM}"`
188      DEVFILE="-D $DEVFILE"
189    fi
190    $NETPERF -t $TEST -l $TEST_TIME -H $HOST -P0 -v0 -- \
191      $COW $DEVFILE $SAP $RR_SIZE $SEND_SIZE $SOCKET_SIZE &
192  done
193}
194
195start_n_procs_per_host() {
196  PROC=0
197  while [ $PROC -lt $1 ]
198  do
199    PROCNUM=`expr $PROC \* ${NHOSTS}`
200    start_1_proc_per_host &
201    PROC=`expr $PROC + 1`
202  done
203  wait
204}
205
206run_1_test() {
207	start_n_procs_per_host $PROCS_PER_HOST |\
208          awk 'BEGIN {max=0;min=99999;sum=0;n=0}				\
209             {sum += $1;n++;ave=sum/n} 					\
210             $1<min {min=$1} 						\
211             $1>max {max=$1} 						\
212             {errl=(ave-min)/ave;errm=(max-ave)/ave;err=errl}		\
213             errm>errl {err=errm}					\
214             END {printf "Aggregate throughput: %2.2f TPS  +/- %2.2f %%\n",sum,err*100}'
215}
216
217run_test_n_times() {
218  RETRY=0
219  TEST_COUNT=0
220  while [ $TEST_COUNT -lt $1 ]
221  do
222    TEST_COUNT=`expr $TEST_COUNT + 1`
223    start_gprof
224    run_1_test > .run_test_n_file
225    cat .run_test_n_file
226    ERROR_LVL=`awk '{print int($6+0.99)}' .run_test_n_file`
227    if [ $ERROR_LVL -gt $TOLERANCE ]
228    then
229      RETRY=`expr $RETRY + 1`
230      if [ $RETRY -le $MAX_RETRIES ]
231      then
232        TEST_COUNT=`expr $TEST_COUNT - 1`
233        TEST_TIME=`expr $TEST_TIME \* 2`
234      else
235	echo "!!!This is an INVALID RUN of the arr_script!!!" >&2
236	echo "!!!UNABLE to hit TOLERANCE of " $TOLERANCE "!!!" >&2
237	echo "Please select a longer initial time and try again." >&2
238       exit
239      fi
240    fi
241  done
242}
243
244do_req_rr_sizes() {
245  for S2 in $RR_SIZES
246    do
247      RR_SIZE="-r $S2"
248      display_test_banner $NPROCS $TEST $S2
249      run_test_n_times $NTEST > .do_series_file
250      TPS=`awk "int(\$6+0.99)<=$TOLERANCE {print}" .do_series_file |\
251        awk 'BEGIN {sum=0;n=1}	\
252             sum>0 {n++}	\
253             {sum+=$3}		\
254             END {printf "%2.2f\n",(sum)/(n)}'`
255    SOCK_SEND=`echo $SOCKET_SIZE | awk '{print $2}'`
256    SOCK_RECV=`echo $SOCKET_SIZE | awk '{print $4}'`
257    REQ_SIZE=`echo $S2 | awk -F"," '{print $1}'`
258    RSP_SIZE=`echo $S2 | awk -F"," '{print $2}'`
259    echo  $SOCK_SEND $SOCK_RECV $REQ_SIZE $RSP_SIZE $TEST_TIME $TPS $PROCS |\
260    awk '{printf "%5d  %5d  %5d    %5d   %5d    %8.2f   %5d",$1,$2,$3,$4,$5,$6,$7}'
261    done
262}
263
264tcp_test() {
265    #Run the TCP RR tests
266    TEST="TCP_RR"
267    SEND_SIZE=""
268    SOCKET_SIZE="-s 8192 -S 8192"
269    COW="-V"
270    do_req_rr_sizes
271    echo
272}
273
274udp_test() {
275    #Run the UDP RR tests
276    TEST="UDP_RR"
277    SEND_SIZE=""
278    SOCKET_SIZE="-s 9216 -S 9216"
279    COW="-V"
280    do_req_rr_sizes
281    echo
282}
283
284lla_test() {
285    #Run the UDP RR tests
286    TEST="HIPPI_RR"
287    SEND_SIZE=""
288    SOCKET_SIZE=""
289    COW=""
290    build_sap_list
291    do_req_rr_sizes
292    echo
293}
294
295do_req_procs() {
296  if [ $TCP -eq 1 ]
297  then
298    TESTNAME="TCP"
299    display_headstone
300    for PROCS in $NPROC_LIST
301      do
302        #Determine number of procs per host
303        PROCS_PER_HOST=`echo $PROCS $REM_HOST_LIST | awk '{printf "%d",($1+NF-2)/(NF-1)}'`
304        NPROCS=`expr $PROCS_PER_HOST \* $NHOSTS`
305        tcp_test
306      done
307  fi
308
309  if [ $UDP -eq 1 ]
310  then
311    TESTNAME="UDP"
312    display_headstone
313    for PROCS in $NPROC_LIST
314      do
315        #Determine number of procs per host
316        PROCS_PER_HOST=`echo $PROCS $REM_HOST_LIST | awk '{printf "%d",($1+NF-2)/(NF-1)}'`
317        NPROCS=`expr $PROCS_PER_HOST \* $NHOSTS`
318        udp_test
319      done
320  fi
321
322  if [ $LLA -eq 1 ]
323  then
324    TESTNAME="LLA"
325    display_headstone
326    for PROCS in $NPROC_LIST
327      do
328        #Determine number of procs per host
329        PROCS_PER_HOST=`echo $PROCS $REM_HOST_LIST | awk '{printf "%d",($1+NF-2)/(NF-1)}'`
330        NPROCS=`expr $PROCS_PER_HOST \* $NHOSTS`
331        lla_test
332      done
333  fi
334}
335
336######################################################################
337
338init_parms
339
340PARMS="${0##*/} ${@}"
341
342# Parse the command line
343while [ $# != 0 ]
344do
345  case $1 in
346    \-gprof) GPROF=1
347             GPROF_KERNEL=$2
348             shift
349             ;;
350    \-t)     TEST_TIME=$2
351             shift
352           ;;
353    \-n)     NPROC_LIST="$NPROC_LIST $2"
354             shift
355             ;;
356    \+lla)   LLA=1
357             ;;
358    \+tcp)   TCP=1
359             ;;
360    \+udp)   UDP=1
361             ;;
362    \-lla)   LLA=0
363             ;;
364    \-tcp)   TCP=0
365             ;;
366    \-udp)   UDP=0
367             ;;
368    \-d)     DEVFILELIST="$DEVFILELIST $2"
369             shift
370             ;;
371    \-r)     RR_SIZES="$RR_SIZES $2"
372             shift
373             ;;
374    \-*)     usage $0: ERROR: Unexpected paramter: $1
375             exit
376             ;;
377    *)       REM_HOST_LIST="$REM_HOST_LIST $1"
378             ;;
379  esac
380  shift
381done
382
383set_default_parms
384check_usage
385do_req_procs
386
387