diff options
Diffstat (limited to 'scripts/contrib/test_build_time.sh')
| -rwxr-xr-x | scripts/contrib/test_build_time.sh | 223 |
1 files changed, 0 insertions, 223 deletions
diff --git a/scripts/contrib/test_build_time.sh b/scripts/contrib/test_build_time.sh deleted file mode 100755 index 4012ac7ba7..0000000000 --- a/scripts/contrib/test_build_time.sh +++ /dev/null | |||
| @@ -1,223 +0,0 @@ | |||
| 1 | #!/bin/bash | ||
| 2 | |||
| 3 | # Build performance regression test script | ||
| 4 | # | ||
| 5 | # Copyright 2011 Intel Corporation | ||
| 6 | # | ||
| 7 | # SPDX-License-Identifier: GPL-2.0-or-later | ||
| 8 | # | ||
| 9 | # DESCRIPTION | ||
| 10 | # This script is intended to be used in conjunction with "git bisect run" | ||
| 11 | # in order to find regressions in build time, however it can also be used | ||
| 12 | # independently. It cleans out the build output directories, runs a | ||
| 13 | # specified worker script (an example is test_build_time_worker.sh) under | ||
| 14 | # TIME(1), logs the results to TEST_LOGDIR (default /tmp) and returns a | ||
| 15 | # value telling "git bisect run" whether the build time is good (under | ||
| 16 | # the specified threshold) or bad (over it). There is also a tolerance | ||
| 17 | # option but it is not particularly useful as it only subtracts the | ||
| 18 | # tolerance from the given threshold and uses it as the actual threshold. | ||
| 19 | # | ||
| 20 | # It is also capable of taking a file listing git revision hashes to be | ||
| 21 | # test-applied to the repository in order to get past build failures that | ||
| 22 | # would otherwise cause certain revisions to have to be skipped; if a | ||
| 23 | # revision does not apply cleanly then the script assumes it does not | ||
| 24 | # need to be applied and ignores it. | ||
| 25 | # | ||
| 26 | # Please see the help output (syntax below) for some important setup | ||
| 27 | # instructions. | ||
| 28 | # | ||
| 29 | # AUTHORS | ||
| 30 | # Paul Eggleton <paul.eggleton@linux.intel.com> | ||
| 31 | |||
| 32 | |||
| 33 | syntax() { | ||
| 34 | echo "syntax: $0 <script> <time> <tolerance> [patchrevlist]" | ||
| 35 | echo "" | ||
| 36 | echo " script - worker script file (if in current dir, prefix with ./)" | ||
| 37 | echo " time - time threshold (in seconds, suffix m for minutes)" | ||
| 38 | echo " tolerance - tolerance (in seconds, suffix m for minutes or % for" | ||
| 39 | echo " percentage, can be 0)" | ||
| 40 | echo " patchrevlist - optional file listing revisions to apply as patches on top" | ||
| 41 | echo "" | ||
| 42 | echo "You must set TEST_BUILDDIR to point to a previously created build directory," | ||
| 43 | echo "however please note that this script will wipe out the TMPDIR defined in" | ||
| 44 | echo "TEST_BUILDDIR/conf/local.conf as part of its initial setup (as well as your" | ||
| 45 | echo "~/.ccache)" | ||
| 46 | echo "" | ||
| 47 | echo "To get rid of the sudo prompt, please add the following line to /etc/sudoers" | ||
| 48 | echo "(use 'visudo' to edit this; also it is assumed that the user you are running" | ||
| 49 | echo "as is a member of the 'wheel' group):" | ||
| 50 | echo "" | ||
| 51 | echo "%wheel ALL=(ALL) NOPASSWD: /sbin/sysctl -w vm.drop_caches=[1-3]" | ||
| 52 | echo "" | ||
| 53 | echo "Note: it is recommended that you disable crond and any other process that" | ||
| 54 | echo "may cause significant CPU or I/O usage during build performance tests." | ||
| 55 | } | ||
| 56 | |||
| 57 | # Note - we exit with 250 here because that will tell git bisect run that | ||
| 58 | # something bad happened and stop | ||
| 59 | if [ "$1" = "" ] ; then | ||
| 60 | syntax | ||
| 61 | exit 250 | ||
| 62 | fi | ||
| 63 | |||
| 64 | if [ "$2" = "" ] ; then | ||
| 65 | syntax | ||
| 66 | exit 250 | ||
| 67 | fi | ||
| 68 | |||
| 69 | if [ "$3" = "" ] ; then | ||
| 70 | syntax | ||
| 71 | exit 250 | ||
| 72 | fi | ||
| 73 | |||
| 74 | if ! [[ "$2" =~ ^[0-9][0-9m.]*$ ]] ; then | ||
| 75 | echo "'$2' is not a valid number for threshold" | ||
| 76 | exit 250 | ||
| 77 | fi | ||
| 78 | |||
| 79 | if ! [[ "$3" =~ ^[0-9][0-9m.%]*$ ]] ; then | ||
| 80 | echo "'$3' is not a valid number for tolerance" | ||
| 81 | exit 250 | ||
| 82 | fi | ||
| 83 | |||
| 84 | if [ "$TEST_BUILDDIR" = "" ] ; then | ||
| 85 | echo "Please set TEST_BUILDDIR to a previously created build directory" | ||
| 86 | exit 250 | ||
| 87 | fi | ||
| 88 | |||
| 89 | if [ ! -d "$TEST_BUILDDIR" ] ; then | ||
| 90 | echo "TEST_BUILDDIR $TEST_BUILDDIR not found" | ||
| 91 | exit 250 | ||
| 92 | fi | ||
| 93 | |||
| 94 | git diff --quiet | ||
| 95 | if [ $? != 0 ] ; then | ||
| 96 | echo "Working tree is dirty, cannot proceed" | ||
| 97 | exit 251 | ||
| 98 | fi | ||
| 99 | |||
| 100 | if [ "BB_ENV_PASSTHROUGH_ADDITIONS" != "" ] ; then | ||
| 101 | echo "WARNING: you are running after sourcing the build environment script, this is not recommended" | ||
| 102 | fi | ||
| 103 | |||
| 104 | runscript=$1 | ||
| 105 | timethreshold=$2 | ||
| 106 | tolerance=$3 | ||
| 107 | |||
| 108 | if [ "$4" != "" ] ; then | ||
| 109 | patchrevlist=`cat $4` | ||
| 110 | else | ||
| 111 | patchrevlist="" | ||
| 112 | fi | ||
| 113 | |||
| 114 | if [[ timethreshold == *m* ]] ; then | ||
| 115 | timethreshold=`echo $timethreshold | sed s/m/*60/ | bc` | ||
| 116 | fi | ||
| 117 | |||
| 118 | if [[ $tolerance == *m* ]] ; then | ||
| 119 | tolerance=`echo $tolerance | sed s/m/*60/ | bc` | ||
| 120 | elif [[ $tolerance == *%* ]] ; then | ||
| 121 | tolerance=`echo $tolerance | sed s/%//` | ||
| 122 | tolerance=`echo "scale = 2; (($tolerance * $timethreshold) / 100)" | bc` | ||
| 123 | fi | ||
| 124 | |||
| 125 | tmpdir=`grep "^TMPDIR" $TEST_BUILDDIR/conf/local.conf | sed -e 's/TMPDIR[ \t]*=[ \t\?]*"//' -e 's/"//'` | ||
| 126 | if [ "x$tmpdir" = "x" ]; then | ||
| 127 | echo "Unable to determine TMPDIR from $TEST_BUILDDIR/conf/local.conf, bailing out" | ||
| 128 | exit 250 | ||
| 129 | fi | ||
| 130 | sstatedir=`grep "^SSTATE_DIR" $TEST_BUILDDIR/conf/local.conf | sed -e 's/SSTATE_DIR[ \t\?]*=[ \t]*"//' -e 's/"//'` | ||
| 131 | if [ "x$sstatedir" = "x" ]; then | ||
| 132 | echo "Unable to determine SSTATE_DIR from $TEST_BUILDDIR/conf/local.conf, bailing out" | ||
| 133 | exit 250 | ||
| 134 | fi | ||
| 135 | |||
| 136 | if [ `expr length $tmpdir` -lt 4 ] ; then | ||
| 137 | echo "TMPDIR $tmpdir is less than 4 characters, bailing out" | ||
| 138 | exit 250 | ||
| 139 | fi | ||
| 140 | |||
| 141 | if [ `expr length $sstatedir` -lt 4 ] ; then | ||
| 142 | echo "SSTATE_DIR $sstatedir is less than 4 characters, bailing out" | ||
| 143 | exit 250 | ||
| 144 | fi | ||
| 145 | |||
| 146 | echo -n "About to wipe out TMPDIR $tmpdir, press Ctrl+C to break out... " | ||
| 147 | for i in 9 8 7 6 5 4 3 2 1 | ||
| 148 | do | ||
| 149 | echo -ne "\x08$i" | ||
| 150 | sleep 1 | ||
| 151 | done | ||
| 152 | echo | ||
| 153 | |||
| 154 | pushd . > /dev/null | ||
| 155 | |||
| 156 | rm -f pseudodone | ||
| 157 | echo "Removing TMPDIR $tmpdir..." | ||
| 158 | rm -rf $tmpdir | ||
| 159 | echo "Removing TMPDIR $tmpdir-*libc..." | ||
| 160 | rm -rf $tmpdir-*libc | ||
| 161 | echo "Removing SSTATE_DIR $sstatedir..." | ||
| 162 | rm -rf $sstatedir | ||
| 163 | echo "Removing ~/.ccache..." | ||
| 164 | rm -rf ~/.ccache | ||
| 165 | |||
| 166 | echo "Syncing..." | ||
| 167 | sync | ||
| 168 | sync | ||
| 169 | echo "Dropping VM cache..." | ||
| 170 | #echo 3 > /proc/sys/vm/drop_caches | ||
| 171 | sudo /sbin/sysctl -w vm.drop_caches=3 > /dev/null | ||
| 172 | |||
| 173 | if [ "$TEST_LOGDIR" = "" ] ; then | ||
| 174 | logdir="/tmp" | ||
| 175 | else | ||
| 176 | logdir="$TEST_LOGDIR" | ||
| 177 | fi | ||
| 178 | rev=`git rev-parse HEAD` | ||
| 179 | logfile="$logdir/timelog_$rev.log" | ||
| 180 | echo -n > $logfile | ||
| 181 | |||
| 182 | gitroot=`git rev-parse --show-toplevel` | ||
| 183 | cd $gitroot | ||
| 184 | for patchrev in $patchrevlist ; do | ||
| 185 | echo "Applying $patchrev" | ||
| 186 | patchfile=`mktemp` | ||
| 187 | git show $patchrev > $patchfile | ||
| 188 | git apply --check $patchfile &> /dev/null | ||
| 189 | if [ $? != 0 ] ; then | ||
| 190 | echo " ... patch does not apply without errors, ignoring" | ||
| 191 | else | ||
| 192 | echo "Applied $patchrev" >> $logfile | ||
| 193 | git apply $patchfile &> /dev/null | ||
| 194 | fi | ||
| 195 | rm $patchfile | ||
| 196 | done | ||
| 197 | |||
| 198 | sync | ||
| 199 | echo "Quiescing for 5s..." | ||
| 200 | sleep 5 | ||
| 201 | |||
| 202 | echo "Running $runscript at $rev..." | ||
| 203 | timeoutfile=`mktemp` | ||
| 204 | /usr/bin/time -o $timeoutfile -f "%e\nreal\t%E\nuser\t%Us\nsys\t%Ss\nmaxm\t%Mk" $runscript 2>&1 | tee -a $logfile | ||
| 205 | exitstatus=$PIPESTATUS | ||
| 206 | |||
| 207 | git reset --hard HEAD > /dev/null | ||
| 208 | popd > /dev/null | ||
| 209 | |||
| 210 | timeresult=`head -n1 $timeoutfile` | ||
| 211 | cat $timeoutfile | tee -a $logfile | ||
| 212 | rm $timeoutfile | ||
| 213 | |||
| 214 | if [ $exitstatus != 0 ] ; then | ||
| 215 | # Build failed, exit with 125 to tell git bisect run to skip this rev | ||
| 216 | echo "*** Build failed (exit code $exitstatus), skipping..." | tee -a $logfile | ||
| 217 | exit 125 | ||
| 218 | fi | ||
| 219 | |||
| 220 | ret=`echo "scale = 2; $timeresult > $timethreshold - $tolerance" | bc` | ||
| 221 | echo "Returning $ret" | tee -a $logfile | ||
| 222 | exit $ret | ||
| 223 | |||
