|
| 1 | +#!/bin/bash |
| 2 | +# Copyright (c) 2023 Oracle Corporation |
| 3 | +# Licensed under the Universal Permissive License v 1.0 |
| 4 | +# as shown at https://oss.oracle.com/licenses/upl/ |
| 5 | + |
| 6 | +. oltp-setup-env |
| 7 | + |
| 8 | +# This is the core script that runs |
| 9 | +# the Max Throughput Insert Test |
| 10 | + |
| 11 | +# Changes |
| 12 | +# |
| 13 | +# bengsig 10-may-2023 Creation |
| 14 | + |
| 15 | +# If stdin is not a tty |
| 16 | +# show how we were called |
| 17 | +tty -s || echo $0 $* |
| 18 | + |
| 19 | +options="i:d:bo:gGn:k:r:hHp:s:a2x:R:WK:t: -l integer:,double:,help,extraout:,runfile:,runnumberfile:,startseconds:,threadcount:,processcount:,key:,runperiod:,avoidtruncate,awrwait,awrkill:,qegraphs,graphs,no-awr,mtit-xc" |
| 20 | +usage="$commandname [-h|H] [-g|-G] [-a] [-W] [-K n] [-n processes] [-t threads] [-k key] [-r runperiod] [-R runfile] [-p file] [-s file] [-o file] komment text ..." |
| 21 | +runperiod=295 |
| 22 | + |
| 23 | +awrWait=no |
| 24 | +awrKill=15 |
| 25 | +extraout='' |
| 26 | +mtitxc=no |
| 27 | +doawr=1 |
| 28 | + |
| 29 | +procs=1 |
| 30 | +runnumberfile=runnumber.txt |
| 31 | +startsecondsfile=startseconds.txt |
| 32 | +runfile=mtitrun.rwl |
| 33 | +help=no |
| 34 | +key='' |
| 35 | +graphs=no |
| 36 | +dotruncate=yes |
| 37 | +killfile='' |
| 38 | +extra_args='' |
| 39 | + |
| 40 | +unset RWLOLTP_SIDE |
| 41 | + |
| 42 | +getopt -Q -o $options -- "$@" || exit 1 |
| 43 | +set -- `getopt -u -n $commandname -o $options -- "$@"` |
| 44 | + |
| 45 | +while test $1 != '--' |
| 46 | +do |
| 47 | + case $1 in |
| 48 | + -i|--integer|-d|--double) extra_args="$extra_args $1 $2"; shift; shift; |
| 49 | + ;; |
| 50 | + -t|--threadcount) extra_args="$extra_args -i mtit_threads:=$2"; shift; shift; |
| 51 | + ;; |
| 52 | + -o|--extraout) extraout=$2; shift; shift; |
| 53 | + ;; |
| 54 | + -s|--startseconds) startsecondsfile=$2; shift; shift; |
| 55 | + ;; |
| 56 | + -R|--runfile) runfile=$2; shift; shift; |
| 57 | + ;; |
| 58 | + -x|--killfile) killfile=$2; shift; shift; |
| 59 | + ;; |
| 60 | + -p|--runnumberfile) runnumberfile=$2; shift; shift; |
| 61 | + ;; |
| 62 | + -n|--processcount) procs=$2; shift; shift; |
| 63 | + ;; |
| 64 | + -k|--key) key=$2; shift; shift; |
| 65 | + ;; |
| 66 | + -r|--runperiod) runperiod=$2; shift; shift; |
| 67 | + ;; |
| 68 | + -a|--avoidtruncate) dotruncate=no; shift; |
| 69 | + ;; |
| 70 | + -W|--awrwait) awrWait=yes; shift; |
| 71 | + ;; |
| 72 | + -K|--awrkill) awrKill=$2; shift; shift; |
| 73 | + ;; |
| 74 | + --no-awr) doawr=0; shift; |
| 75 | + ;; |
| 76 | + --mtit-xc) mtitxc=yes; shift; |
| 77 | + ;; |
| 78 | + -G|--qegraphs) graphs=qe; shift; |
| 79 | + ;; |
| 80 | + -g|--graphs) graphs=yes; shift; |
| 81 | + ;; |
| 82 | + -h|-H|--help) help=yes; shift; |
| 83 | + ;; |
| 84 | + ?) |
| 85 | + exit 1 |
| 86 | + ;; |
| 87 | + esac; |
| 88 | +done |
| 89 | +shift |
| 90 | +extrakomment="$*" |
| 91 | + |
| 92 | +if test x$help = xyes |
| 93 | +then |
| 94 | +echo "$usage" |
| 95 | +cat <<END |
| 96 | +-H --help : show this help |
| 97 | +-n --processcount N : specify number of processes |
| 98 | +-t --threadcount N : specify number of threads |
| 99 | +-k --key key : set the value of the key to be used in repository, default $RWLOLTP_NAME |
| 100 | +-r --runperiod N : set the runperiod in seconds, default $runperiod |
| 101 | +-g --graphs : show running graphs - requires X windows |
| 102 | +-G --qegraphs : show alternative running graphs - requires X windows |
| 103 | +-a --avoidtruncate : do not truncate the tables before start |
| 104 | +-p --runnumberfile file : put the runnumber into file (default $runnumberfile) |
| 105 | +-s --startseconds file : put the startseconds into file (default $startsecondsfile) |
| 106 | +-R --runfile file : name of the runfile (default $runfile) |
| 107 | +-W --awrwait : Always wait for runsys rather than kill |
| 108 | +-K --awrkill nn : Time to sleep before final kill (15) |
| 109 | +--mtit-xc : Run will have external control enabled |
| 110 | +END |
| 111 | +exit 0 |
| 112 | +fi |
| 113 | + |
| 114 | +if test x$killfile != x |
| 115 | +then |
| 116 | + echo $$ > $killfile |
| 117 | +fi |
| 118 | + |
| 119 | +if test x$key = x |
| 120 | +then |
| 121 | + echo key set to the default of $RWLOLTP_NAME |
| 122 | + key=$RWLOLTP_NAME |
| 123 | +fi |
| 124 | + |
| 125 | +if test $procs -lt 1 |
| 126 | +then |
| 127 | + echo -p $procs is too low 1>&2 |
| 128 | + exit 1 |
| 129 | +fi |
| 130 | + |
| 131 | +if test $procs -gt 8 |
| 132 | +then |
| 133 | + echo -p $procs is reduced to 8, use higher thread count to increase load 1>&2 |
| 134 | + procs=8 |
| 135 | +fi |
| 136 | + |
| 137 | +if test $runperiod -lt 30 |
| 138 | +then |
| 139 | + echo -r $runperiod is less than 30 seconds 1>&2 |
| 140 | + exit 1 |
| 141 | +fi |
| 142 | + |
| 143 | + |
| 144 | +rwloadsim parameters.rwl || exit $? |
| 145 | + |
| 146 | +# Check parameters.rwl is silent |
| 147 | +shouldbezero=`rwloadsim -q parameters.rwl | wc -c` |
| 148 | +if test "$shouldbezero" -ne 0 |
| 149 | +then |
| 150 | + echo "output from 'rwloadsim parameters.rwl' must be empty. These lines found:" |
| 151 | + rwloadsim -q parameters.rwl |
| 152 | + exit 1 |
| 153 | +fi |
| 154 | + |
| 155 | +# Set shell variables |
| 156 | +eval `rwloadsim -q -i proccount:=$procs -i runperiod:=$runperiod parameters2shell.rwl` |
| 157 | + |
| 158 | +# verify that it compiles |
| 159 | +rwloadsim -u -v $extra_args -e -- '-x $mute:141' $runfile || exit $? |
| 160 | + |
| 161 | +if test $mtitxc = yes |
| 162 | +then |
| 163 | + mtitxcset --key=$key --no-stopnow |
| 164 | + mtitsetxc='-i mtit_xc:=1' |
| 165 | + oltpsetxc='-i xc_enabled:=1' |
| 166 | +else |
| 167 | + mtitsetxc='' |
| 168 | + oltpsetxc='' |
| 169 | +fi |
| 170 | + |
| 171 | +# also allocate new partitions in orders and order_itmes |
| 172 | +test $dotruncate = yes && rwloadsim -q mtit_truncate.rwl |
| 173 | + |
| 174 | +procnumber=1; |
| 175 | + |
| 176 | +# Rampup 5 seconds plus proccount * script_ramp |
| 177 | +# is calculated in parameters2shell since bash |
| 178 | +# cannot work with double |
| 179 | + |
| 180 | +prepfile=`mktemp` |
| 181 | +trap "rm -f $prepfile" 0 int |
| 182 | + |
| 183 | +# Remove \ " and ' from komment, causes issues in gnuplot and probably other places |
| 184 | +komment=`echo $RWLOLTP_NAME $rwl_title $extrakomment | sed 's/[\\"'"']//g"` |
| 185 | + |
| 186 | +# prepare the run; this will also create the $resultsdir/$subdir/$runnumber/env file |
| 187 | +if test $mtitxc = yes |
| 188 | +then |
| 189 | + rwloadsim -u -v -c 15 -sss -P $prepfile -k $key -K "$komment" -q \ |
| 190 | + --fulltitle="$komment" \ |
| 191 | + -i runperiod:=$runperiod -i proccount:=$procs prepare.rwl |
| 192 | + mute59='-x$mute:59' |
| 193 | +else |
| 194 | + rwloadsim -u -v -c $rampup -sss -P $prepfile -k $key -K "$komment" -q \ |
| 195 | + --fulltitle="$komment" \ |
| 196 | + -i runperiod:=$runperiod -i proccount:=$procs prepare.rwl |
| 197 | + mute59='' |
| 198 | +fi |
| 199 | + |
| 200 | +# cat $prepfile |
| 201 | + |
| 202 | + |
| 203 | +# Get runnumber and variables from the env file |
| 204 | +runnumber=`cut -f1 -d: $prepfile` |
| 205 | +# get the subdirectory under resultsdir/awrdirectory |
| 206 | +eval `rwloadsim -q -R $prepfile subdir.rwl` |
| 207 | +. $resultsdir/$subdir/$runnumber/env |
| 208 | + |
| 209 | +sed 's/^.*.:\([0-9][0-9]*\)\..*$/\1/' $prepfile > $startsecondsfile |
| 210 | +echo $runnumber > $runnumberfile |
| 211 | + |
| 212 | + |
| 213 | +echo "runperiod=$runperiod" >> $resultsdir/$subdir/$runnumber/env |
| 214 | +echo "komment='$komment'" >> $resultsdir/$subdir/$runnumber/env |
| 215 | +#if test $pool_type = sessionpool -o $pool_type = connectionpool |
| 216 | +#then |
| 217 | +# echo "plotactive=yes" >> $resultsdir/$subdir/$runnumber/env |
| 218 | +#else |
| 219 | + echo "plotactive=no" >> $resultsdir/$subdir/$runnumber/env |
| 220 | +#fi |
| 221 | +# rwloadsim -q $mtitsetxc $extra_args -i runperiod:=$runperiod -i proccount:=$procs -i show_changed_values:=1 -x 'string key_to_show := "'$key'";' parameters.rwl > $resultsdir/$subdir/$runnumber/parmatstart.txt |
| 222 | + |
| 223 | +rwloadsim -q $mtitsetxc $extra_args --htmlformat -R $prepfile mtit_showparam.rwl > $resultsdir/$subdir/$runnumber/mtitplotinfo.html |
| 224 | + |
| 225 | +if test x$killfile != x |
| 226 | +then |
| 227 | + echo $! >> $killfile |
| 228 | +fi |
| 229 | + |
| 230 | +markerfile='string(1000)xc_marker_file:="'$resultsdir/$subdir/$runnumber/markers.txt'";' |
| 231 | +quiet='' |
| 232 | + |
| 233 | +# Start sys gather |
| 234 | +rwloadsim $mute59 $oltpsetxc -u -A 1 -r -q -i procnumber:=99999 -i runperiod:=$runperiod -i proccount:=$procs -R $prepfile -i doawr:=$doawr runsys.rwl $starttime & |
| 235 | +awrpid=$! |
| 236 | + |
| 237 | +if test x$killfile != x |
| 238 | +then |
| 239 | + echo $awrpid >> $killfile |
| 240 | +fi |
| 241 | + |
| 242 | +# show countdown to user |
| 243 | +echo -n '**** remaining:' |
| 244 | +# Start the real workers |
| 245 | +while test $procnumber -le $procs |
| 246 | +do |
| 247 | + sleep $script_ramp |
| 248 | + echo -n " "`expr $procs - $procnumber` |
| 249 | + rwloadsim $mute59 -u -r -i procnumber:=$procnumber \ |
| 250 | + --flush-stop=$runperiod --flush-every=2 -v -i runperiod:=$runperiod \ |
| 251 | + --procno $procnumber \ |
| 252 | + -W -i doawr:=$doawr -x "$markerfile" $mtitsetxc $extra_args -i proccount:=$procs -R $prepfile $quiet $runfile & |
| 253 | + quiet='-q' # only messages from first |
| 254 | + procnumber=`expr $procnumber + 1` |
| 255 | + if test x$killfile != x |
| 256 | + then |
| 257 | + echo $! >> $killfile |
| 258 | + fi |
| 259 | + |
| 260 | +done |
| 261 | +echo |
| 262 | +echo '****' started all background jobs at `date` |
| 263 | + |
| 264 | +sleep 3 |
| 265 | +# show running graph of dbcpu and dbtime |
| 266 | +test $graphs != no && rwloadsim $oltpsetxc $extra_args -u -q -R $prepfile plotfigures.rwl -x 'string(128)pool_type:="dedicated";' -i runperiod:=$runperiod ';' $runnumber | gnuplot $RWLOLTP_GNUPLOT1 & |
| 267 | + |
| 268 | +# show running graph of throughput |
| 269 | +test $graphs = yes && rwloadsim $mtitsetxc $extra_args -u -q -R $prepfile mtitplotrun.rwl -i runperiod:=$runperiod ';' $runnumber | gnuplot $RWLOLTP_GNUPLOT2 & |
| 270 | + |
| 271 | +# show running graph of queue/exec time |
| 272 | +test $graphs = qe && rwloadsim $mtitsetxc $extra_args -u -q -R $prepfile mtitplotwe.rwl -i runperiod:=$runperiod ';' $runnumber | gnuplot $RWLOLTP_GNUPLOT2 & |
| 273 | + |
| 274 | +# with external control, we simply wait |
| 275 | +if test $mtitxc = no |
| 276 | +then |
| 277 | + sleep $runperiod |
| 278 | + echo '****' runperiod=$runperiod over at `date` |
| 279 | + sleep `expr $rampup / 10 + 10` |
| 280 | + echo '****' `expr $rampup / 10 + 10` extra seconds over at `date` |
| 281 | + sleep 30 |
| 282 | + echo '****' looking for still running processes at `date` |
| 283 | + # we previousle were sleeping for 30 seconds more than runperiod plus |
| 284 | + # rampup before killing, however, we already are delayed due to |
| 285 | + # $script_ramp * $proccount sleeps in the loop above that starts |
| 286 | + # the real workers. |
| 287 | + # all jobs really ought to be terminated now |
| 288 | + # show a list to the user |
| 289 | + # jobs -lr |
| 290 | + JOBS="$(jobs -pr | grep -v $awrpid)" |
| 291 | + # send first kill except to the one doing awr and wait 30 seconds |
| 292 | + if test -n "$JOBS" |
| 293 | + then |
| 294 | + echo sending first kill to $JOBS |
| 295 | + ps -fp $JOBS |
| 296 | + kill -s int $JOBS |
| 297 | + sleep 30 |
| 298 | + fi |
| 299 | + |
| 300 | + # again |
| 301 | + # jobs -lr |
| 302 | + JOBS="$(jobs -pr | grep -v $awrpid)" |
| 303 | + if test -n "$JOBS" |
| 304 | + then |
| 305 | + echo sending second kill to $JOBS |
| 306 | + ps -fp $JOBS |
| 307 | + kill -s int $JOBS |
| 308 | + sleep $awrKill |
| 309 | + fi |
| 310 | + |
| 311 | + # again with term, also to the one doing awr |
| 312 | + # jobs -lr |
| 313 | + if test $awrWait = yes |
| 314 | + then |
| 315 | + JOBS="$(jobs -pr | grep -v $awrpid)" |
| 316 | + else |
| 317 | + JOBS="$(jobs -pr)" |
| 318 | + fi |
| 319 | + if test -n "$JOBS" |
| 320 | + then |
| 321 | + echo sending third kill to $JOBS |
| 322 | + ps -fp $JOBS |
| 323 | + kill $JOBS |
| 324 | + fi |
| 325 | +fi |
| 326 | + |
| 327 | +wait |
| 328 | + |
| 329 | +# If running without external control, or run finished without stopnow |
| 330 | +#if test $mtitxc = no || mtitxcset | grep -q stopnow=0 |
| 331 | +#then |
| 332 | + |
| 333 | + # copy the ash data from systemdb to results db |
| 334 | + rwloadsim -u -A 2 -q ashstep2.rwl $runnumber $runperiod & |
| 335 | + |
| 336 | + # and make the awr reports |
| 337 | + test $doawr -ne 0 && rwloadsim -u -A 1 -q makeawr.rwl $runnumber & |
| 338 | + |
| 339 | + wait |
| 340 | + # Done, do the various graphs |
| 341 | + |
| 342 | + # This takes generated data in $resultsdir/$subdir/$runnumber as input |
| 343 | + mtitplot --xcolor black $runnumber |
| 344 | + |
| 345 | +#else |
| 346 | +# # just make the awr reports |
| 347 | +# test $doawr -ne 0 && rwloadsim -u -A 1 -q makeawr.rwl $runnumber |
| 348 | +# # and do the plot without showing stderr which is likely to |
| 349 | +# # have lots of gnuplot errors due to missing data |
| 350 | +# test $doawr -ne 0 && mtitplot $runnumber 2> /dev/null |
| 351 | +#fi |
| 352 | + |
| 353 | +echo "run number $runnumber completed" |
0 commit comments