使用bootchart 对 高通Android 进行性能分析

Android版本:7.0

适用平台:高通和MTK

参考:

bootchart 简介

bootchart 是一个用于 linux 启动过程性能分析的开源工具软件,在系统启动过程中自动收集 CPU 占用率、磁盘吞吐率、进程等信息,并以图形方式显示分析结果,可用作指导优化系统启动过程。

bootchart 让用户可以很直观的查看系统启动的过程和各个过程耗费的时间,以便让用户能够分析启动过程,从而进行优化以提高启动时间。

它由 bootchartd 服务和 bootchart-render 两部分组成,后者主要负责生成启动流程的分析结果图。

Android 系统源码中有 bootchart 的实现,路径在 system/core/init/bootchart.cpp 中, bootchart 通过内嵌在 init 进程中实现,在后台执行测量。不过 bootchart 的测量时段是 init 进程启动之后,不包含 uboot 和 kernel 的启动时间。

参考文档:system/core/init/readme.txt中的Bootcharting这一章

  1. Bootcharting
  2. ------------
  3. This version of init contains code to perform "bootcharting": generating log
  4. files that can be later processed by the tools provided by www.bootchart.org.
  5. On the emulator, use the -bootchart <timeout> option to boot with bootcharting
  6. activated for <timeout> seconds.
  7. On a device, create /data/bootchart/start with a command like the following:
  8. adb shell 'echo $TIMEOUT > /data/bootchart/start'
  9. Where the value of $TIMEOUT corresponds to the desired bootcharted period in
  10. seconds. Bootcharting will stop after that many seconds have elapsed.
  11. You can also stop the bootcharting at any moment by doing the following:
  12. adb shell 'echo 1 > /data/bootchart/stop'
  13. Note that /data/bootchart/stop is deleted automatically by init at the end of
  14. the bootcharting. This is not the case with /data/bootchart/start, so don't
  15. forget to delete it when you're done collecting data.
  16. The log files are written to /data/bootchart/. A script is provided to
  17. retrieve them and create a bootchart.tgz file that can be used with the
  18. bootchart command-line utility:
  19. sudo apt-get install pybootchartgui
  20. # grab-bootchart.sh uses $ANDROID_SERIAL.
  21. $ANDROID_BUILD_TOP/system/core/init/grab-bootchart.sh
  22. One thing to watch for is that the bootchart will show init as if it started
  23. running at 0s. You'll have to look at dmesg to work out when the kernel
  24. actually started init.
  25. Comparing two bootcharts
  26. ------------------------
  27. A handy script named compare-bootcharts.py can be used to compare the
  28. start/end time of selected processes. The aforementioned grab-bootchart.sh
  29. will leave a bootchart tarball named bootchart.tgz at /tmp/android-bootchart.
  30. If two such barballs are preserved on the host machine under different
  31. directories, the script can list the timestamps differences. For example:
  32. Usage: system/core/init/compare-bootcharts.py base_bootchart_dir
  33. exp_bootchart_dir
  34. process: baseline experiment (delta)
  35. - Unit is ms (a jiffy is 10 ms on the system)
  36. ------------------------------------
  37. /init: 50 40 (-10)
  38. /system/bin/surfaceflinger: 4320 4470 (+150)
  39. /system/bin/bootanimation: 6980 6990 (+10)
  40. zygote64: 10410 10640 (+230)
  41. zygote: 10410 10640 (+230)
  42. system_server: 15350 15150 (-200)
  43. bootanimation ends at: 33790 31230 (-2560)

bootchart 在 android 平台的使用步骤

编译 bootchart

在 Android 5.1 之前 bootchart 是没有编译进系统的,需要使用下面的宏手动打开编译,在 Android 6.0 以上系统默认已经编译了 bootchart,

可以 adb shell 命令进入文件系统,可以看到 /data/bootchart 目录存在。

打开 bootchart 收集开机数据

0、修改高通代码:system/core/init/Android.mk,删掉下列这一行,重新编译烧录boot.imgsystem.img

如果没有此步骤,将导致手机不断重启,无法开机。

  1. LOCAL_SANITIZE := integer

安卓7.1的代码。一直不断重启:system/core/init/bootchart.cpp 这个文件有bug

  • stat.replace(open + 1, close - open - 1, full_name); 这个函数注释不跑就不会一直重启了,但是这样对你bootchart造成多大影响你看看,是否还能分析。

1、首先使能 bootchart,bootchart 操作的前提是存在 enable 标记

所以 在你不需要收集数据的时候别忘了删除这个标记。

  1. adb shell 'touch /data/bootchart/enabled'

2、抓取

  1. adb shell 'echo $TIME_OUT > /data/bootchart/start' # 添加 bootchart timeout 时间
  2. adb shell reboot # 重启后生效

其中$TIMEOUT是期望采样的时间,单位为秒,例如要采样两分钟,则执行:

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

3、提取

可以看到 bootchart 生成的数据文件和 log 都被保存在 /data/bootchart 路径下,打包以后使用 adb pull 命令将文件拷贝出来

下列的命令也可以使用:system/core/init/grab-bootchart.sh代替

  1. adb shell 'cd /data/bootchart ;tar -zcf boochart.tgz *'

在 HOST 机上分析 bootchart 图表

PC 机安装 bootchart 工具

  1. sudo apt-get install -y pybootchartgui

生成 bootchar 图表

拷贝 bootchart.tgz 到 PC 中,并执行下面的命令生成图表

  1. bootchart bootchart.tgz

bootchart 图形分析小技巧

整个图表以时间线为横轴,图标上方为 CPU 和 磁盘的利用情况,下方是各进程的运行状态条,显示各个进程的开始时间与结束时间以及对 CPU、I/O 的利用情况,我们关心的各个进程的运行时间以及 CPU 的使用情况,进而优化系统。

可以通过 Laucher 的启动时间判断开机完成完成时间

通过进程的时间长短判断是否存在异常,如图表上的 第一个 Zygote 进程启动时间很短,显示存在异常,后又成功重新启动了一遍。

使用bootchart 对 高通Android 进行性能分析的更多相关文章

  1. 高通Android平台硬件调试之Camera篇

    之前一段时间有幸在高通android平台上调试2款camera sensor,一款是OV的5M YUV sensor,支持jpeg out,同时也支持AF,调试比较比较简单,因为别的项目已经在使用了, ...

  2. 高通Android display架构分析

    目录(?)[-] Kernel Space Display架构介绍 函数和数据结构介绍 函数和数据结构介绍 函数和数据结构介绍 数据流分析 初始化过程分析 User Space display接口 K ...

  3. 高通Android display分析【转】

    本文转载自:http://blog.csdn.net/zhangchiytu/article/details/6777039 高通7系列硬件架构分析 如上图,高通7系列 Display的硬件部分主要由 ...

  4. JVM 利用 VisualVM 对高并发项目进行性能分析(转)

    出处:  深入理解 Java 虚拟机-如何利用 VisualVM 对高并发项目进行性能分析 前面在学习JVM的知识的时候,一般都需要利用相关参数进行分析,而分析一般都需要用到一些分析的工具,因为一般使 ...

  5. 深入理解Java虚拟机-如何利用VisualVM对高并发项目进行性能分析

    前面在学习JVM的知识的时候,一般都需要利用相关参数进行分析,而分析一般都需要用到一些分析的工具,因为一般使用IDEA,而VisualVM对于IDEA也不错,所以就选择VisualVM来分析JVM性能 ...

  6. 高通android开发摘要

    一部分是开源的,可以从codeaurora.org上下载,还有一部分是高通产权的,需要从高通的网站上下载. 将高通产权的代码放到:vendor/qcom/proprietary 1. 设置bms一些参 ...

  7. 高通Android camera运行流程【转】

    本文转载自:http://blog.csdn.net/unicornkylin/article/details/13293295 1.总体架构 Android Camera 框架从整体上看是一个 cl ...

  8. 高通android开发缩写

    1.TLMM MSM TLMM pinmux controller,Qualcomm MSM integrates a GPIO and Pin mux/config hardware, (TOP L ...

  9. 高通 android平台LCD驱动分析

    目前手机芯片厂家提供的源码里包含整个LCD驱动框架,一般厂家会定义一个xxx_fb.c的源文件,注册一个平台设备和平台驱动,在驱动的probe函数中来调用register_framebuffer(), ...

  10. 【转】高通平台android 环境配置编译及开发经验总结

    原文网址:http://blog.csdn.net/dongwuming/article/details/12784535 1.高通平台android开发总结 1.1 搭建高通平台环境开发环境 在高通 ...

随机推荐

  1. 解决HtmlUnit执行JS报错提示ScriptException

    问题描述 HtmlUnit作为一款比Selenium更轻量的HeadLess的Java版本浏览器模拟器,不需要在服务器上安装部署浏览器及其Driver程序. 但是,众所周知,HtmlUnit对JS脚本 ...

  2. n个人围成一圈,顺序排号从1到n。从第一个人开始报数(从一到三如此循环)。凡是报到三的出局,最后剩下的一个人原始编号为?

    #include<stdio.h> int main(){ int num,n,i=0,flag=0; //num记录剩余人数,n记录总人数,i为原始编号,flag为编号123时的编号 p ...

  3. Splashtop 扩展了所有 Android 8.0 以上设备的远程控制功能

    好消息:Splashtop远程访问和远程支持软件现在支持100多个品牌的 Android 设备. 2020年9月15日,远程访问和远程支持解决方案的全球领导者 Splashtop Inc. 宣布:所有 ...

  4. PAT 练习2-3 输出倒三角图案

    结果: 本题要求编写程序,输出指定的由"*"组成的倒三角图案. 输入格式: 本题目没有输入. 输出格式: 按照下列格式输出由"*"组成的倒三角图案. 一般都用的 ...

  5. C 语言编程 — 异常处理

    目录 文章目录 目录 前文列表 异常处理 perror() 和 strerror() 输出异常信息 程序退出状态 前文列表 <程序编译流程与 GCC 编译器> <C 语言编程 - 基 ...

  6. 国产系统UOS安装体验

    原文链接 https://www.giantliu.cn/2020/09/04/200904InstallUOS/ UOS简介 统信桌面操作系统(Uniontech OS)个人正式版是统信软件基于Li ...

  7. PageOffice 6 版本最简单的打开保存文件

    在OA办公.文档流转等各个Web系统中,实现最简单的打开编辑保存文件功能,调用PageOffice只需要几行代码就可以完成. 后端代码 在后端编写代码调用webOpen方法打开文件之前给SaveFil ...

  8. go高并发之路——缓存穿透、缓存雪崩

    缓存击穿.缓存穿透.缓存雪崩是使用Redis的三个经典问题,上篇文章讲了缓存击穿,今天就讲下剩下的两个问题. 一.缓存穿透 定义:缓存穿透是指查询一个根本不存在的数据,缓存层和DB层都不会命中.这样缓 ...

  9. C# WPF 自定义Main方法总结

    在使用自定义的Main函数启动应用时,应该需要做这几步: 1.去掉App.xaml的Application的starup属性. 2.右键App.xaml,属性 把生成操作改为Page. 3.如果有引入 ...

  10. RocketMQ主从同步原理

    一. 主从同步概述 主从同步这个概念相信大家在平时的工作中,多少都会听到.其目的主要是用于做一备份类操作,以及一些读写分离场景.比如我们常用的关系型数据库mysql,就有主从同步功能在. 主从同步,就 ...