Application of bootchart tool in Android system boot Measurement

Source: Internet
Author: User
Tags touch command

Bootchart is an open-source tool that visually analyzes the performance of the Startup Process of gun/Linux, including resource usage, such as CPU and disk, the execution time of each process. Based on the analysis results, determine the performance bottleneck of the system startup and formulate corresponding optimization policies. Official Website: Click to open the link

The Android system already has a C Implementation of bootchart, which is located in system/CORE/init/bootchart. C. Bootchart is implemented in the INIT process for Android boot measurement, and the measurement is performed in the background. However, the measurement period of bootchart is from the initialization time of bootchart to the home screen time, excluding the execution time of Bootloader and kernel.

My system is ubuntu10.04. The usage steps are summarized as follows:

1) install the bootchart tool in Ubuntu

2) bootchart compilation in Android

3) bootchart execution in Android

4) Graphical process of bootchart measurement results

The preceding steps are described in detail below.

1. Install the bootchart tool in Ubuntu

The tool to be installed includes two bootcharts and pybootchartgui. The command is as follows:

sudo apt-get install bootchartsudo apt-get install pybootchartgui

2. bootchart compilation in Android

During Android compilation, the bootchart compilation function is disabled by default, that is, the bootchart is not compiled into the system. Bootchart compilation systems need to be divided into two situations:

1) if the system has not been compiled or the make clean command is executed, run the following command:

$ cd mydroid$ export INIT_BOOTCHART=true$ make clean$ make

2) The system has been compiled. Now, you only need to add the bootchart to the system and run the following command :'

$ touch system/core/init/init.c$ m INIT_BOOTCHART=true

The touch command is used to set init. the last modification time of the C file is changed to the current time to ensure init. c file will be re-make, and bootchart is in init. C to ensure that the bootchart will be compiled into the system.

3. bootchart execution in Android

1} re-download the compiled Android system with the bootchart tool to the Development Board and start the system.

2) connect to the Development Board through ADB connect on Ubuntu, and then execute:

       $ adb shell 'echo 120 > /data/bootchart-start'

3) execute the command:

       $ adb shell 'mkdir /data/bootchart'

Create a directory bootchart/in the/data/directory of the system on the Development Board to store the measurement results of the bootchart. Then, use these files to generate visual images.

4) restart the Development Board and view the following files in the/data/bootchart/directory of the android System of the Development Board:

# ls -l-rw-rw-rw- root     root          452 2010-01-01 00:00 header-rw-r--r-- root     root            0 2010-01-01 00:00 kernel_pacct-rwxr-xr-x root     root      1020195 2010-01-01 00:02 proc_diskstats.log-rwxr-xr-x root     root      4252966 2010-01-01 00:02 proc_ps.log-rwxr-xr-x root     root       138215 2010-01-01 00:02 proc_stat.log

So far, the measurement data generated after bootchart executes the measurement has been completed. Check that there are three. log files on it. The following data needs to be further processed into a readable and analytical image.

4. graphical process of bootchart measurement results

1) Here, I would like to praise Android for its intimacy. I have written a script to package the data generated by bootchart measurement from the Development Board and generate bootchart. tgz. This packaging script is the source code of the system/CORE/init/grab-bootchart.sh file, and bootchart source code is located in the same directory. The script content is as follows:

#!/bin/sh## this script is used to retrieve the bootchart log generated# by init when compiled with INIT_BOOTCHART=true.## for all details, see //device/system/init/README.BOOTCHART#TMPDIR=/tmp/android-bootchartrm -rf $TMPDIRmkdir -p $TMPDIRLOGROOT=/data/bootchartTARBALL=bootchart.tgzFILES="header proc_stat.log proc_ps.log proc_diskstats.log kernel_pacct"for f in $FILES; do    adb pull $LOGROOT/$f $TMPDIR/$f 2>&1 > /dev/nulldone(cd $TMPDIR && tar -czf $TARBALL $FILES)cp -f $TMPDIR/$TARBALL ./$TARBALLecho "look at $TARBALL"

From the logroot field of the script, we can see that in step 3 of step 3, the Directory of the new file that stores the bootchart measurement results cannot be changed at will, make sure that the Created directory is consistent with the logroot entry of the script. The bootchart. tgz file is generated in the current directory, namely system/CORE/init.

2) run the following command in the directory where bootchart. tgz is located:

       $bootchart ./bootchart.tgz

In this way, bootchart.png is generated under the system/CORE/init/directory, as shown in


5. Problem Summary

When you execute step 2, execute the following command:

    $bootchart ./bootchart.tgz

The following error is reported:

parsing './bootchart.tgz'parsing 'header'parsing 'proc_stat.log'parsing 'proc_ps.log'warning: no parent for pid '2' with ppid '0'parsing 'proc_diskstats.log'parsing 'kernel_pacct'merged 0 logger processespruned 61 process, 0 exploders, 2 threads, and 0 runsFalseTraceback (most recent call last):  File "/usr/bin/bootchart", line 23, in <module>    sys.exit(main())  File "/usr/lib/pymodules/python2.7/pybootchartgui/main.py", line 137, in main    render()  File "/usr/lib/pymodules/python2.7/pybootchartgui/main.py", line 128, in render    batch.render(writer, res, options, filename)  File "/usr/lib/pymodules/python2.7/pybootchartgui/batch.py", line 41, in render    draw.render(ctx, options, *res)  File "/usr/lib/pymodules/python2.7/pybootchartgui/draw.py", line 282, in render    draw_chart(ctx, IO_COLOR, True, chart_rect, [(sample.time, sample.util) for sample in disk_stats], proc_tree)  File "/usr/lib/pymodules/python2.7/pybootchartgui/draw.py", line 201, in draw_chart    yscale = float(chart_bounds[3]) / max(y for (x,y) in data)ZeroDivisionError: float division by zero

When something went wrong, I was very annoyed. I found a circle and finally solved it. For specific solutions, see connection: Click the open link and find it on the Link Page.
Draw. py,Parsing. py,Samples. pyDownload the three files, replace the corresponding files under/usr/share/pyshared/pybootchartgui/on Ubuntu, and run the following command again:

bootchart ./bootchart.tgz

You can. If you haven't encountered any of the above problems, it's both a good news and a pity !!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.