Bootchart

From WebOS Internals
Jump to: navigation, search
« Go Back to the application list
Bootchart.png

Bootchart - GNU Utility


What it is

Bootchart is a tool for performance analysis and visualization of the GNU/Linux boot process. Resource utilization and process information are collected during the boot process and are later rendered in a PNG, SVG or EPS encoded chart. Its home page is http://www.bootchart.org. Bootchart is distributed under the GNU General Public License v.2.


Configuration

There is only one config file that you need to be concerned with: /etc/bootchart.conf. This is the default file:

#
# Configuration for bootchartd, the bootchart logger script.
#

# tmpfs size
# (32 MB should suffice for ~20 minutes worth of log data, but YMMV)
TMPFS_SIZE=32m

# Lock file
BOOTLOG_LOCK=".lock"

# Sampling period (in milliseconds)
# Default 200000 is not fine enough to catch peculiarities in OE-based distro
SAMPLE_PERIOD=10000

# Whether to enable and store BSD process accounting information.  The
# kernel needs to be configured to enable v3 accounting
# (CONFIG_BSD_PROCESS_ACCT_V3). accton from the GNU accounting utilities
# is also required.
PROCESS_ACCOUNTING="yes"

# Tarball for the various boot log files
BOOTLOG_DEST="/var/log/bootchart.tgz"

# Whether to automatically generate the boot chart once the boot logger
# completes.  The boot chart will be generated in $AUTO_RENDER_DIR.
# Note that the bootchart package must be installed.
AUTO_RENDER="no"

# Image format to use for the auto-generated boot chart
# (choose between png, svg and eps).
AUTO_RENDER_FORMAT="svg"

# Output directory for auto-generated boot charts
AUTO_RENDER_DIR="/var/log"

In order to enable bootchart to run at boot time, you need to run: '/sbin/bootchart_enable'. Before rebooting your phone, you need to make one change in the config file. Change the line that says "AUTO_RENDER" to "yes".


Getting Data

Here's the catch. The bootchart_enable script copies a special init file in place of the real init file that the kernel starts actually booting the OS itself with. This special init file calls bootchart (among other things). In this special init file is this line:

# Render the chart if configured (and the renderer is installed)

[ "$AUTO_RENDER" = "yes" -a -x /usr/bin/bootchart ] && \ /usr/bin/bootchart -o "$AUTO_RENDER_DIR" -f $AUTO_RENDER_FORMAT "$BOOTLOG_DEST"

That program (/usr/bin/bootchart) does not exist in webOS, so bootchart cannot autorender the chart for you. In my experimenting however, if the config was NOT set to "autorender", the dump files from bootchart were not created at all. I don't know why this is yet.

To get webOS to creat teh logs needed for a pretty bootchart chart, simply reboot the phone after making the config file change. The boot will be MUCH slower than usual, and it will be slow once the OS is done booting as well. The raw logs will be in "/bootchart".

cp -r /bootchart/ /media/internal/

That will get yourself a copy of the logs.


Render Chart

Once you have a copy of the logs, disable bootchart for the next boot:

/sbin/bootchart_disable

You may want to reboot your phone now since it will be running VERY slow. As far as I can tell, bootchart is trying in vain to find the renderer and is in a constant state of trying and failing (because the renderer doesn't exist in the webOS distro).

The directory of logs will be 32Meg in size. You may want to "zip" it

cd /media/internal/bootchart
tar --remove-files -czvf * bootchart.tgz

You now need to get bootchart.tgz onto a Linux machine that *does* have bootchart installed. On Gentoo, simply "emerge bootchart".

Once on the Linux machine (assuming you put bootchart.tgz - adjust accordingly if you didn't):

cd ~/bootchart
bootchart -o ./ -f png bootchart.tgz

You will now have "bootchart.png" in that same directory. You can change the file format (-f) to svg if you want a scalable graphic.


What It Means

To be honest, webOS's bootchart is a mess. webOS's bootchart:

webOS 1.4.1.1 - Stock Kernel
Bootchart.png

Here's two bootcharts from my main personal machine (Gentoo). I have disabled and enabled "parallel booting" (starting all boot services in parallel vs. "serial").

Gentoo Parallel Boot Disabled Gentoo Parallel Boot Enabled
Bootchart nop.png
Bootchart p.png

You see from the Gentoo charts what a system that has a sense of order should look like. You should also see (plain as day...) why it's important for apps to send the "Done!" signal back to the caller. webOS's init is FULL of "sleep" commands because exit status seems to never be called back to init, so they make everything sleep hoping that the services started. See this comment in /etc/init.d/watchdog.sh:

# How long should watchdog's timer be?  It takes 8 seconds from when I
# emit control-alt-delete until the logs stop.  10 or 15 would suffice
# in that case, and I doubt the user will still have the battery in
# place if it stays hung for 60 seconds.

So even though it's been timed out, they muse about an additional 2 to 7 seconds to be safe, but they set it to 60:

SLEEP_SECONDS=60

This is just one example of how much more stream lined the boot process can be made to be.


Conclusion

I don't have much to go on. The webOS bootchart is a mess and I don't know where to start yet. It's a hacked together kludge of shell scripts estimating when system services should be done loading, not getting a call back from them saying that they are done.