summaryrefslogtreecommitdiffstats
path: root/scripts/contrib
diff options
context:
space:
mode:
authorStefan Stanacar <stefanx.stanacar@intel.com>2013-03-29 17:10:20 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-03-29 16:23:10 +0000
commit5769b5971fdf58c0cf97ffb6fc7268b7fb802601 (patch)
treef95acdcd67a940a725581e087d564cbc92398b3a /scripts/contrib
parentfd900c17630d8fef52f6c73918a4e700b1a6edc8 (diff)
downloadpoky-5769b5971fdf58c0cf97ffb6fc7268b7fb802601.tar.gz
scripts/contrib/build-perf-test.sh: add a script for build performance tracking
This script runs a series of builds (core-image-sato by default) with and without sstate cache and collects some metrics (time and size currently). It takes a commit as argument (-c <rev>) and measures wall clock for bitbake core-image-sato and virtual/kernel. (From OE-Core rev: ee9538081a0bccfb7eb2888b1b51fe9b71c8cb81) Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/contrib')
-rwxr-xr-xscripts/contrib/build-perf-test.sh301
1 files changed, 301 insertions, 0 deletions
diff --git a/scripts/contrib/build-perf-test.sh b/scripts/contrib/build-perf-test.sh
new file mode 100755
index 0000000000..2d70cfae52
--- /dev/null
+++ b/scripts/contrib/build-perf-test.sh
@@ -0,0 +1,301 @@
1#!/bin/bash
2#
3# This script runs a series of tests (with and without sstate) and reports build time (and tmp/ size)
4#
5# Build performance test script
6#
7# Copyright 2013 Intel Corporation
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, write to the Free Software
21# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22#
23#
24# AUTHORS:
25# Stefan Stanacar <stefanx.stanacar@intel.com>
26
27
28ME=$(basename $0)
29
30#
31# usage and setup
32#
33
34usage () {
35cat << EOT
36Usage: $ME [-h]
37 $ME [-c <commit>] [-v] [-m <val>] [-j <val>] [-t <val>] [-i <image-name>] [-d <path>]
38Options:
39 -h
40 Display this help and exit.
41 -c <commit>
42 git checkout <commit> before anything else
43 -v
44 Show bitbake output, don't redirect it to a log.
45 -m <machine>
46 Value for MACHINE. Default is qemux86.
47 -j <val>
48 Value for PARALLEL_MAKE. Default is 8.
49 -t <val>
50 Value for BB_NUMBER_THREADS. Default is 8.
51 -i <image-name>
52 Instead of timing agains core-image-sato, use <image-name>
53 -d <path>
54 Use <path> as DL_DIR
55
56Note: current working directory must be inside a poky git clone.
57
58EOT
59}
60
61
62if clonedir=$(git rev-parse --show-toplevel); then
63 cd $clonedir
64else
65 echo "The current working dir doesn't seem to be a poky git clone. Please cd there before running $ME"
66 exit 1
67fi
68
69IMAGE="core-image-sato"
70verbose=0
71dldir=
72commit=
73pmake=
74while getopts "hvc:m:j:t:i:d:" opt; do
75 case $opt in
76 h) usage
77 exit 0
78 ;;
79 v) verbose=1
80 ;;
81 c) commit=$OPTARG
82 ;;
83 m) export MACHINE=$OPTARG
84 ;;
85 j) pmake=$OPTARG
86 ;;
87 t) export BB_NUMBER_THREADS=$OPTARG
88 ;;
89 i) IMAGE=$OPTARG
90 ;;
91 d) dldir=$OPTARG
92 ;;
93 *) usage
94 exit 1
95 ;;
96 esac
97done
98
99
100#drop cached credentials and test for sudo access without a password
101sudo -k -n ls > /dev/null 2>&1
102reqpass=$?
103if [ $reqpass -ne 0 ]; then
104 echo "The script requires sudo access to drop caches between builds (echo 3 > /proc/sys/vm/drop_caches)"
105 read -s -p "Please enter your sudo password: " pass
106 echo
107fi
108
109if [ -n "$commit" ]; then
110 echo "git checkout $commit"
111 git checkout $commit || exit 1
112 git pull || exit 1
113fi
114
115rev=$(git rev-parse --short HEAD) || exit 1
116OUTDIR="$clonedir/build-perf-test/results-$rev-`date "+%Y%m%d%H%M%S"`"
117BUILDDIR="$OUTDIR/build"
118resultsfile="$OUTDIR/results.log"
119bboutput="$OUTDIR/bitbake.log"
120myoutput="$OUTDIR/output.log"
121
122mkdir -p $OUTDIR || exit 1
123
124log () {
125 local msg="$1"
126 echo "`date`: $msg" | tee -a $myoutput
127}
128
129
130#
131# Config stuff
132#
133
134log "Git revision is $rev"
135
136source ./oe-init-build-env $OUTDIR/build >/dev/null
137cd $OUTDIR/build
138
139[ -n "$MACHINE" ] || export MACHINE="qemux86"
140[ -n "$BB_NUMBER_THREADS" ] || export BB_NUMBER_THREADS="8"
141
142if [ -n "$pmake" ]; then
143 export PARALLEL_MAKE="-j $pmake"
144else
145 export PARALLEL_MAKE="-j 8"
146fi
147
148if [ -n "$dldir" ]; then
149 echo "DL_DIR = \"$dldir\"" >> conf/local.conf
150else
151 echo "DL_DIR = \"$clonedir/build-perf-test/downloads\"" >> conf/local.conf
152fi
153
154#
155# Functions
156#
157
158bbtime () {
159 log "Running and timing bitbake $1"
160 if [ $verbose -eq 0 ]; then
161 /usr/bin/time -v -o $resultsfile bitbake "$1" >> $bboutput
162 else
163 /usr/bin/time -v -o $resultsfile bitbake "$1"
164 fi
165 ret=$?
166 if [ $ret -eq 0 ]; then
167 log "Finished bitbake $1"
168 else
169 log "Exit status was non-zero. Exit..."
170 exit $ret
171 fi
172
173 log "Time: `grep wall $resultsfile`"
174 #time by default overwrites the output file and we want to keep the results
175 #it has an append option but I don't want to clobber the results in the same file
176 i=`ls $OUTDIR/results.log* |wc -l`
177 mv $resultsfile "${resultsfile}.${i}"
178 log "More stats can be found in ${resultsfile}.${i}"
179}
180
181#we don't time bitbake here
182bbnotime () {
183 log "Running bitbake $1"
184 if [ $verbose -eq 0 ]; then
185 bitbake "$1" >> $bboutput
186 else
187 bitbake "$1"
188 fi
189 ret=$?
190 if [ $ret -eq 0 ]; then
191 log "Finished bitbake $1"
192 else
193 log "Exit status was non-zero. Exit.."
194 exit $?
195 fi
196
197}
198
199do_rmtmp() {
200 log "Removing tmp"
201 rm -rf bitbake.lock pseudone tmp conf/sanity_info
202}
203do_rmsstate () {
204 log "Removing sstate-cache"
205 rm -rf sstate-cache
206}
207do_sync () {
208 log "Syncing and dropping caches"
209 sync; sync
210 if [ $reqpass -eq 0 ]; then
211 sudo sh -c "echo 3 > /proc/sys/vm/drop_caches"
212 else
213 echo "$pass" | sudo -S sh -c "echo 3 > /proc/sys/vm/drop_caches"
214 echo
215 fi
216 sleep 3
217}
218
219####
220
221#
222# Test 1
223# Measure: Wall clock of "bitbake core-image-sato" and size of tmp/dir (w/o rm_work and w/ rm_work)
224# Pre: Downloaded sources, no sstate
225# Steps:
226# Part1:
227# - fetchall
228# - clean build dir
229# - time bitbake core-image-sato
230# - collect data
231# Part2:
232# - bitbake virtual/kernel -c
233# - time bitbake virtual/kernel
234# Part3:
235# - add INHERIT to local.conf
236# - clean build dir
237# - build
238# - report size, remove INHERIT
239
240test1_p1 () {
241log "Running Test 1, part 1/3: Measure wall clock of bitbake $IMAGE and size of tmp/ dir"
242bbnotime "$IMAGE -c fetchall"
243do_rmtmp
244do_rmsstate
245do_sync
246bbtime "$IMAGE"
247log "Size of tmp dir is: `du -hc tmp | grep total`"
248log "Buildstats are saved in $OUTDIR/buildstats-test1"
249mv tmp/buildstats $OUTDIR/buildstats-test1
250}
251
252
253test1_p2 () {
254log "Running Test 1, part 2/3: bitbake virtual/kernel -c clean && cleansstate and time bitbake virtual/kernel"
255bbnotime "virtual/kernel -c clean"
256bbnotime "virtual/kernel -c cleansstate"
257do_sync
258bbtime "virtual/kernel"
259}
260
261test1_p3 () {
262log "Running Test 1, part 3/3: Build $IMAGE w/o sstate and report size of tmp/dir with rm_work enabled"
263echo "INHERIT += \"rm_work\"" >> conf/local.conf
264do_rmtmp
265do_rmsstate
266do_sync
267bbtime "$IMAGE"
268log "Size of tmp dir is: `du -hc tmp | grep total`"
269sed -i 's/INHERIT += \"rm_work\"//' conf/local.conf
270}
271
272
273#
274# Test 2
275# Measure: Wall clock of "bitbake core-image-sato" and size of tmp/dir
276# Pre: populated sstate cache
277
278test2 () {
279#assuming test 1 has run
280log "Running Test 2: Measure wall clock of bitbake $IMAGE -c rootfs with sstate"
281do_rmtmp
282do_sync
283bbtime "$IMAGE -c rootfs"
284}
285
286
287# RUN!
288
289test1_p1
290test1_p2
291test1_p3
292test2
293
294log "All done."
295
296
297
298
299
300
301