TipsAndTricks/InvestigatingBuildTime

From Yocto Project
Revision as of 22:14, 14 November 2016 by Leonardo Sandoval (talk | contribs)
Jump to navigationJump to search

Investigating Build Time

(Placeholder. Demonstrate use of buildstats and pybootchartgui)

The buildstats data produce by the class with the same name if included in USER_CLASSES variable provides process statistics for every task. This data can offer insight of the time spent by the builder (bitbake) when constructing a particular target at process level. This article focus more on profiling than optimization, the former being the base for the latter.

Setup

 $ cd poky
 $ git checkout -b morty origin/morty
 $ . oe-init-build-env
 $ bitbake world

Build Machine

Build time depends on the build machine HW and for this particular article we use a Linux box with the following characteristics:


Buildstats

There are two set of process' stat data: time and IO stats. For the moment, the time stats to be used are the following:


  • /proc/[pid]/stat: utime, stime
  • /proc/[pid]/stat: cutime, cstime
  • python resource module: rusage ru_utime, rusage ru_stime
  • python resource module: Child rusage ru_utime, Child rusage ru_stime

and the following IO stats:

  • /proc/[pid]/io: IO rchar, IO wchar
  • /proc/[pid]/io: IO read_bytes, IO write_bytes

With this separation of buildstats, proceed running the following script (once the bitbake world command has finished) to plot the top N stat consumers

$ ../scripts/contrib/bb-perf/buildstats-plot.sh -s <BUILDSTATS> -N $N | gnuplot -p

In case we want a more general picture, getting data per task type instead of recipe's task, the script needs -S (for Sum) argument

$ ../scripts/contrib/bb-perf/buildstats-plot.sh -s <BUILDSTATS> -S | gnuplot -p


Results

$ IMAGE='set terminal png fontscale 1 size 1280,720; set output "IO-write_bytes:IO-read_bytes.png"'

utime and stime

Time spent by a certain process can be obtain looking at the stime< and time corresponding to the amount of time the process has been scheduled in kernel and user mode.

$ IMAGE='set terminal png fontscale 1 size 1280,720; set output "IO-write_bytes:IO-read_bytes.png"'
$ ../scripts/contrib/bb-perf/buildstats-plot.sh -s 'stime:utime' -N 20 > input.gpl; gnuplot -e "\'$IMAGE\'" input.gpl
$ ../scripts/contrib/bb-perf/buildstats-plot.sh -s 'stime:utime' -S | gnuplot -p