Timechart how-to
Developer builds contain a performance analysis command called perf
that can
be used to create an SVG output file similar to bootchart
; the chart shows how
CPU cycles and I/O wait times are distributed across processes in the system
over time.
Below is a short primer in four lessons describing how to generate and view
output from perf timechart
.
Lesson 1 - a simple example
-
Boot ChromiumOS, and open a terminal.
-
Run this command:
sudo perf timechart record
-
Run your workload. A workload isn't necessary if all you want to see is a chart of an idle system. :-)
-
When your workload is done, interrupt the process started in step 2 using ^C, or kill -2.
Explanation: Without arguments, perf timechart record
runs forever
gathering data, until stopped by SIGINT. Note that only SIGINT works; SIGTERM
will kill the process without producing the necessary output. When the command
completes, you'll see two new files: perf.data
and trace.out.
Lesson 2 - how to generate and view the chart
-
In the directory where you ran Lesson 1, run this command:
sudo perf timechart
-
The output image will be stored in a file named
output.svg
. Usescp
or some equivalent to copy the file to another system for viewing.
Tips for viewing: Some browsers may have trouble displaying the image. The author of timechart recommends the Inkscape image editor:
Inkscape does a good job of displaying the fine details, but it may be a bit slow for the large timechart images. You should exercise patience when opening, magnifying, or scroling images.
Lesson 3 - how to avoid using SIGINT
-
Run this command:
sudo perf timechart record sleep 5
-
Run a workload that will finish within 5 seconds; for longer workloads, use a more appropriate sleep time in step 1.
-
Generate and view the output as described in Lesson 2.
Explanation: If there are arguments to perf timechart record
, the
arguments are treated as a command to run as a subprocess of perf. perf
gathers data until the process terminates.
If your workload is triggered by a single command, that command can be used in
place of 'sleep 5'. Note that if the workload acts as a daemon (that is, forks a
child and exits), perf
will terminate with the parent terminates; this likely
isn't what you'd want.
Lesson 4 - how to get a timechart of system boot
-
Install bootchart on your workstation. For ubuntu:
sudo apt-get install bootchart
-
emerge and install bootchart onto your DUT:
emerge-$BOARD bootchart && cros deploy $DUT bootchart
-
reboot DUT
ssh $DUT reboot
-
bootchart will log events in
/var/log/bootchart/boot-<timestamp>.tgz
. It will collect data until the DUT upstart sequence has fully completed. Retrieve the archive(s) withscp $DUT:/var/log/bootchart/boot-<timestamp>.tgz /tmp
-
generate SVG graphics
F=boot-<timestamp> ; bootchart --format=svg -o $F.svg $F.tgz
or in a loop with
scp $DUT:/var/log/bootchart/boot-*.tgz . && for i in *; do F=${i%.tgz}; bootchart --format=svg -o "${F}.svg" "${F}.tgz"; done
The svg file(s) are ready for viewing.