SlideShare a Scribd company logo

Android Boot Time Optimization

Kan-Ru Chen
Kan-Ru ChenDeveloper at Mozilla
Connect your device to application
Android Boot Time
Optimization




Kan-Ru Chen
                    kanru@0xlab.org
                       Sep 09, 2011
Agenda   Motivation
         Boot Time Measurement
         Android Boot Time Analysis
         Reduction Approach
         Hibernation Based Technologies
         We Don't Need Boot-loader
         Demo
         Future Work and Conclusions
Motivation
Boot Time Measurement
Traditional Linux Environment
Printk Times
Linux kernel feature
Built-in since Linux 2.6.11
How to enable?

    Add CONFIG_PRINTK_TIME=y to .config

    Or choose from menuconfig
    Kernel hacking --->
      [*] Show timing information on printks
Printk Times
Output Example
linux$ dmesg
[0.000000] per task-struct memory footprint: 1152 bytes
[0.003692] Calibrating delay loop... 506.27 BogoMIPS (lpj=1978368)
[0.079833] pid_max: default: 32768 minimum: 301
[0.080230] Security Framework initialized
[0.080474] Mount-cache hash table entries: 512
[0.083892] CPU: Testing write buffer coherency: ok

Analysis Tool
linux$ dmesg > timefile
linux$ scripts/show_delta timefile
...
[0.194488 < 0.194488 >] OMAP DMA hardware revision 5.0
[0.259948 < 0.065460 >] bio: create slab <bio-0> at 0
[0.267822 < 0.007874 >] SCSI subsystem initialized
...
initcall_debug
Kernel Parameter
Print the time spent for each initcall
Output Example
calling ipc_init+0x0/0x28 @ 1
msgmni has been set to 42
initcall ipc_init+0x0/0x28 returned 0 after 1872 usecs
Bootchart
Visualize the booting process
Use “bootchartd” to collect CPU and IO utilization
information.
On Ubuntu:
 apt-get install bootchart bootchart-view
Original “bootchartd” is not suitable for embedded
usage.
Bootchart
$ bootchart bootchart.tgz -f png
Strace
Trace system calls during process execution and
output timing information.
$ strace -tt ls
15:11:04.243357 execve("/bin/ls", ["ls"], [/* 51 vars */]) = 0
15:11:04.244252 brk(0)                  = 0x234f000
15:11:04.244458 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT
15:11:04.244676 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|
MAP_ANONYMOUS, -1, 0) = 0x7f1444794000
15:11:04.244852 access("/etc/ld.so.preload", R_OK) = -1 ENOENT
15:11:04.245096 open("/etc/ld.so.cache", O_RDONLY) = 3
OProfile
OProfile is a system-wide profiler for Linux systems.
Capable of profiling all running code at low overhead.
Supports wide number of hardwares.
Profiling daemon ported to Android and available in
AOSP.
OProfile
Output Example
$ opreport --exclude-dependent
CPU: PIII, speed 863.195 MHz (estimated)
Counted CPU_CLK_UNHALTED events (clocks processor is not halted)...
450385 75.6634 cc1plus
 60213 10.1156 lyx
 29313 4.9245 XFree86
 11633 1.9543 as
 10204 1.7142 oprofiled
  7289 1.2245 vmlinux
  7066 1.1871 bash
  6417 1.0780 oprofile
  6397 1.0747 vim
...
Perf
New profiling tool based on the performance counter
subsystem of Linux.
Very powerful and easy to use.
Included in Linux source code:
tools/perf/
Perf
Recording:
$ perf record -a -f
^C
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.288 MB perf.data (~12567 samples)]


Output
$   perf report --sort comm,dso,symbol|head -10
#   Events: 1K cycles
#
#   Overhead       Command            Shared Object         Symbol
#   ........   ...........   ......................   ............
#
      35.47%      firefox    libxul.so                [.]   0xc1b3a7
       3.08%      firefox    libcairo.so.2.11000.2    [.]   0xff88
       2.98%         Xorg    Xorg (deleted)           [.]   0xe201c
       2.51%      firefox    firefox                  [.]   0x2726
       1.49%         Xorg    [kernel.kallsyms]        [k]   find_vma
       0.93%   perf_3.0.0    perf_3.0.0               [.]   hex2u64
Perf
  Timechart
$ perf timechart record
  $ perf timechart
Android Environment
Bootchart
Original “bootchartd” is not suitable on embedded
devices.
Android re-implemented in its “init” program.
Bootchart
To build:
$ cd system/core/init
$ touch init.c
$ mm INIT_BOOTCHART=true
Bootchart
To run:
$ adb shell 'echo 120 > /data/bootchart-start'
Remember the /data directory must be write able
during boot.
Use grab-bootchart.sh to retrieve the data.
Strace
After analyzed the bootchart, can use strace to
analyze individual progarm.
Available in AOSP since Éclair
Strace
Modify init.rc from
service zygote /system/bin/app_process -Xzygote /system/bin 
                             --zygote --start-system-server




To
 service zygote /system/xbin/strace -tt -o/data/boot.strace 
                /system/bin/app_process -Xzygote /system/bin 
                              --zygote --start-system-server
Logcat
Android log utility
Can output timing information
Adjust loglevel to 6 in init.rc

    Displays time spent for each command
Dalvik Method Tracer
Method tracer is built into Dalvik
Use DDMS or using calls inside source to collect data.
// start tracing to "/sdcard/calc.trace"
Debug.startMethodTracing("calc");
// ...
// stop tracing
Debug.stopMethodTracing();
Stopwatch
Not real stopwatch
A utility in Android Framework for measuring C++
code.
Output result to system log
#include <utils/StopWatch.h>
…
{
    StopWatch watch("blah");
    /* your codes here */
}
Q&A
Android Boot Time Analysis
Boot-loader Init
Usually constant time
Avoid init hardware multiple times
Ensure to use maximum CPU frequency
Use faster NAND/MMC reading mechanism
Kernel Init
Mostly usual suspects

    ip_auto_config

    USB init

    Flash driver initialization

Fullow the standard Kernel optimizing guide:
   http://elinux.org/Boot_Time

Avoid loading unneeded kernel module at boot time
Zygote Class Preloading
Android Framework has thousands of Java classes
Preloaded by Zygote and instantiated in its heap
To improve Application startup time and save memory
Controlled by resource: preloaded-classes

    frameworks/base/preloaded-classes
Zygote Class Preloading
Can use the tool in framework to adjust the list:
$ adb logcat > logcat.txt
$ java -p preload.jar Compile logcat.txt logcat.compiled
$ java -p preload.jar PrintCsv logcat.compiled

Google Android Developer Dianne Hackborn said:

    The content of the file is a “black art”

    You can adjust this as much as you like

    But the result maybe suboptimal
PackageManager Package Scannig
Every APK is scanned at boot time
Package management code is inefficient
Uses mmaped files means each access will cause
page fault
ParseZipArchive() scans entire APK for only one
AndroidManifest.xml file
System Services Starting
Last stage of Android boot
Start every base service
Zygote start SystemServer process
Start native service (SurfaceFlinger, AudioFlinger) first
Start each service sequentially
Q&A
Reduction Approach
Boot-loader
Improve U-Boot

    Reading multi-mmc-block

    Cache (I/D) enablement

    Optimize CRC32

    Disable verification
Boot-loader
Qi Boot-loader
                                                        Qi           U-Boot + XLoader
                                                        Boot-oader
                                       Size             ~30K         ~270K+20K

    Only one stage boot-loader         Time to Kernel   <1s          > 5s


    Small footprint ~30K               Usage            Product      Engineering

                                       Code             Simple       Complicated

    Currently support
     −   iMX31
     −   Samsung 24xx
     −   Beagleboard

    KISS concept
     −   Boot device and load kernel
Kernel Boot Time
Fullow the standard Kernel optimizing guide:
   http://elinux.org/Boot_Time

Minimize kernel size
Use compression or not
Enable embedded options
Avoid loading unneeded kernel module at boot time
Optimize Android Init
Parallize init tasks

    insmod cannot be parallized

    Use external scripts to init at background

Start services on demand
Optimize Class Preloading
Trade-off between preload class and application
startup time
Split class to more packages to reduce dependency
Save inited heap for later use
Share heaps between zygote and children
Filesystem Optimization
According to reasearch by Linaro Kernel WG
Use correct NAND configuration will improve the
performance
MMC controllers are often optimized for particular
usage / filesystem
Adjust the filesystem partition scheme
Toothpaste Effect
Observed by Sony Developer Tim Bird
“When you squeeze a tube of toothpaste, sometimes
it just moves the toothpaste somewhere else in the
tube, and nothing actually comes out.”
Q&A
Hibernation Based Technologies
QuickBoot
Developed by Japanese
company Ubiquitous
Demand loading of
required page from flash
Requires deep
integration of hardware
and software
Fast-On
Developed by CCU
Based on existing technologies thus requires little
modification to userspace
Release clean-pages before suspend
Swap out dirty-pages before save image
Image size reduced leads to faster resume time.
Android Wakelocks & TuxOnIce
TuxOnIce Patch
TuxOnIce (was Software Suspend 2) is a hibernation
patchset
Can save images to different locations
Can use different compresion algorithm
Porting to ARM is possible
Android Wakelocks
An aggressive approach to save device power
Use wakelocks to prevent device going suspend
Port TOI to Android have to deal with wakelocks
because MMC driver might hold a wakelock
Linux Suspend Architecture
Documentation/power/devices.txt:
  struct dev_pm_ops {
          int (*prepare)(struct device *dev);
          void (*complete)(struct device *dev);
          int (*suspend)(struct device *dev);
          int (*resume)(struct device *dev);
          int (*freeze)(struct device *dev);
          int (*thaw)(struct device *dev);
          int (*poweroff)(struct device *dev);
          int (*restore)(struct device *dev);
          int (*suspend_noirq)(struct device *dev);
          int (*resume_noirq)(struct device *dev);
          int (*freeze_noirq)(struct device *dev);
          int (*thaw_noirq)(struct device *dev);
          int (*poweroff_noirq)(struct device *dev);
          int (*restore_noirq)(struct device *dev);
          int (*runtime_suspend)(struct device *dev);
          int (*runtime_resume)(struct device *dev);
          int (*runtime_idle)(struct device *dev);
  };
Q&A
We Don't Need Boot-loader
R-Loader
Normal suspend-to-disk approach has many
duplicated effort

    Boot-loader inits some hardwares

    Boot-loader loads the normal kernel image

    Kernel inits some hardwares again

    Kernel loads the suspended kernel image

    Kernel resumes, inits some hardwares again
R-Loader
0xlab Developer Matt Proposed “Resume-Loader”
R-Loader inits some hardware then reads the
suspended kernel image as fast as possible
Jump directly to the resume point
Kernel will takeover the job and inits reset hardwares
Demo
Get 0xdroid 0x7 release
   https://code.google.com/p/0xdroid/wiki/0x7_leb_gingerbread

Get TOI Patch for 0x7 release
   https://gitorious.org/0xlab-kernel/kernel/commits/toi/linaro-android.38
Future Work and Conclusions
Save the heap image (like core dump) of Zygote after
preloading classes
Modify Dalvik to make hibernation image after system
init and before Launcher startup
Parallize Android init
Cache & Share JITed code fragment
Q&A
http://0xlab.org
1 of 59

Android Boot Time Optimization

Download to read offline
Kan-Ru Chen
Kan-Ru ChenDeveloper at Mozilla

Recommended

Android Internals by
Android InternalsAndroid Internals
Android InternalsOpersys inc.
7.8K views39 slides
Deep Dive into the AOSP by
Deep Dive into the AOSPDeep Dive into the AOSP
Deep Dive into the AOSPDr. Ketan Parmar
5.1K views38 slides
Android Internals by
Android InternalsAndroid Internals
Android InternalsOpersys inc.
14.1K views23 slides
Booting Android: bootloaders, fastboot and boot images by
Booting Android: bootloaders, fastboot and boot imagesBooting Android: bootloaders, fastboot and boot images
Booting Android: bootloaders, fastboot and boot imagesChris Simmonds
120.9K views31 slides
Android Security Internals by
Android Security InternalsAndroid Security Internals
Android Security InternalsOpersys inc.
1.9K views68 slides
Shorten Device Boot Time for Automotive IVI and Navigation Systems by
Shorten Device Boot Time for Automotive IVI and Navigation SystemsShorten Device Boot Time for Automotive IVI and Navigation Systems
Shorten Device Boot Time for Automotive IVI and Navigation SystemsNational Cheng Kung University
6.6K views109 slides
Android IPC Mechanism by
Android IPC MechanismAndroid IPC Mechanism
Android IPC MechanismNational Cheng Kung University
67.2K views82 slides
Using and Customizing the Android Framework / part 4 of Embedded Android Work... by
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Using and Customizing the Android Framework / part 4 of Embedded Android Work...
Using and Customizing the Android Framework / part 4 of Embedded Android Work...Opersys inc.
10K views61 slides

More Related Content

What's hot

Embedded Android Workshop with Pie by
Embedded Android Workshop with PieEmbedded Android Workshop with Pie
Embedded Android Workshop with PieOpersys inc.
2K views251 slides
"Learning AOSP" - Android Hardware Abstraction Layer (HAL) by
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)Nanik Tolaram
20.1K views13 slides
Android's HIDL: Treble in the HAL by
Android's HIDL: Treble in the HALAndroid's HIDL: Treble in the HAL
Android's HIDL: Treble in the HALOpersys inc.
14.9K views29 slides
Embedded Android : System Development - Part III (Audio / Video HAL) by
Embedded Android : System Development - Part III (Audio / Video HAL)Embedded Android : System Development - Part III (Audio / Video HAL)
Embedded Android : System Development - Part III (Audio / Video HAL)Emertxe Information Technologies Pvt Ltd
11.9K views69 slides
Android crash debugging by
Android crash debuggingAndroid crash debugging
Android crash debuggingAshish Agrawal
49.3K views26 slides
Q4.11: Porting Android to new Platforms by
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new PlatformsLinaro
4.4K views24 slides
Android Treble: Blessing or Trouble? by
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?Opersys inc.
3.4K views62 slides
Embedded Android : System Development - Part I by
Embedded Android : System Development - Part IEmbedded Android : System Development - Part I
Embedded Android : System Development - Part IEmertxe Information Technologies Pvt Ltd
9.3K views122 slides
Embedded Android : System Development - Part II (HAL) by
Embedded Android : System Development - Part II (HAL)Embedded Android : System Development - Part II (HAL)
Embedded Android : System Development - Part II (HAL)Emertxe Information Technologies Pvt Ltd
10.8K views59 slides
Android device driver structure introduction by
Android device driver structure introductionAndroid device driver structure introduction
Android device driver structure introductionWilliam Liang
5.5K views34 slides
Learning AOSP - Android Linux Device Driver by
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device DriverNanik Tolaram
4.4K views12 slides
Learning AOSP - Android Booting Process by
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting ProcessNanik Tolaram
12.5K views13 slides
Android Booting Sequence by
Android Booting SequenceAndroid Booting Sequence
Android Booting SequenceJayanta Ghoshal
4.5K views11 slides
Android booting sequece and setup and debugging by
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debuggingUtkarsh Mankad
11.6K views44 slides
Android Binder IPC for Linux by
Android Binder IPC for LinuxAndroid Binder IPC for Linux
Android Binder IPC for LinuxYu-Hsin Hung
2.5K views30 slides
Android Automotive by
Android AutomotiveAndroid Automotive
Android AutomotiveOpersys inc.
5.6K views44 slides
Embedded Android Workshop by
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android WorkshopOpersys inc.
2.7K views190 slides
Embedded Android : System Development - Part II (Linux device drivers) by
Embedded Android : System Development - Part II (Linux device drivers)Embedded Android : System Development - Part II (Linux device drivers)
Embedded Android : System Development - Part II (Linux device drivers)Emertxe Information Technologies Pvt Ltd
5.6K views43 slides
A deep dive into Android OpenSource Project(AOSP) by
A deep dive into Android OpenSource Project(AOSP)A deep dive into Android OpenSource Project(AOSP)
A deep dive into Android OpenSource Project(AOSP)Siji Sunny
1.7K views20 slides
Understanding the Android System Server by
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System ServerOpersys inc.
53.7K views25 slides

What's hot (20)

Embedded Android Workshop with Pie by Opersys inc.
Embedded Android Workshop with PieEmbedded Android Workshop with Pie
Embedded Android Workshop with Pie
Opersys inc.2K views
"Learning AOSP" - Android Hardware Abstraction Layer (HAL) by Nanik Tolaram
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
"Learning AOSP" - Android Hardware Abstraction Layer (HAL)
Nanik Tolaram20.1K views
Android's HIDL: Treble in the HAL by Opersys inc.
Android's HIDL: Treble in the HALAndroid's HIDL: Treble in the HAL
Android's HIDL: Treble in the HAL
Opersys inc.14.9K views
Android crash debugging by Ashish Agrawal
Android crash debuggingAndroid crash debugging
Android crash debugging
Ashish Agrawal49.3K views
Q4.11: Porting Android to new Platforms by Linaro
Q4.11: Porting Android to new PlatformsQ4.11: Porting Android to new Platforms
Q4.11: Porting Android to new Platforms
Linaro4.4K views
Android Treble: Blessing or Trouble? by Opersys inc.
Android Treble: Blessing or Trouble?Android Treble: Blessing or Trouble?
Android Treble: Blessing or Trouble?
Opersys inc.3.4K views
Android device driver structure introduction by William Liang
Android device driver structure introductionAndroid device driver structure introduction
Android device driver structure introduction
William Liang5.5K views
Learning AOSP - Android Linux Device Driver by Nanik Tolaram
Learning AOSP - Android Linux Device DriverLearning AOSP - Android Linux Device Driver
Learning AOSP - Android Linux Device Driver
Nanik Tolaram4.4K views
Learning AOSP - Android Booting Process by Nanik Tolaram
Learning AOSP - Android Booting ProcessLearning AOSP - Android Booting Process
Learning AOSP - Android Booting Process
Nanik Tolaram12.5K views
Android booting sequece and setup and debugging by Utkarsh Mankad
Android booting sequece and setup and debuggingAndroid booting sequece and setup and debugging
Android booting sequece and setup and debugging
Utkarsh Mankad11.6K views
Android Binder IPC for Linux by Yu-Hsin Hung
Android Binder IPC for LinuxAndroid Binder IPC for Linux
Android Binder IPC for Linux
Yu-Hsin Hung2.5K views
Android Automotive by Opersys inc.
Android AutomotiveAndroid Automotive
Android Automotive
Opersys inc.5.6K views
Embedded Android Workshop by Opersys inc.
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android Workshop
Opersys inc.2.7K views
A deep dive into Android OpenSource Project(AOSP) by Siji Sunny
A deep dive into Android OpenSource Project(AOSP)A deep dive into Android OpenSource Project(AOSP)
A deep dive into Android OpenSource Project(AOSP)
Siji Sunny1.7K views
Understanding the Android System Server by Opersys inc.
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
Opersys inc.53.7K views

Viewers also liked

Hardware Abstraction Layer by
Hardware Abstraction LayerHardware Abstraction Layer
Hardware Abstraction LayerTeh Kian Cheng
2.2K views8 slides
Diving inside Android Wifi by
Diving inside Android WifiDiving inside Android Wifi
Diving inside Android WifiNanik Tolaram
905 views10 slides
Android Custom Kernel/ROM design by
Android Custom Kernel/ROM designAndroid Custom Kernel/ROM design
Android Custom Kernel/ROM designMuhammad Najmi Ahmad Zabidi
5.5K views45 slides
HKG15-409: ARM Hibernation enablement on SoCs - a case study by
HKG15-409: ARM Hibernation enablement on SoCs - a case studyHKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case studyLinaro
5.3K views22 slides
Android HAL Introduction: libhardware and its legacy by
Android HAL Introduction: libhardware and its legacyAndroid HAL Introduction: libhardware and its legacy
Android HAL Introduction: libhardware and its legacyJollen Chen
19.5K views64 slides
Hibernation in Linux 2.6.29 by
Hibernation in Linux 2.6.29Hibernation in Linux 2.6.29
Hibernation in Linux 2.6.29Varun Mahajan
6.8K views46 slides
Implement Checkpointing for Android (ELCE2012) by
Implement Checkpointing for Android (ELCE2012)Implement Checkpointing for Android (ELCE2012)
Implement Checkpointing for Android (ELCE2012)National Cheng Kung University
4.2K views46 slides
Qi -- Lightweight Boot Loader Applied in Mobile and Embedded Devices by
Qi -- Lightweight Boot Loader Applied in Mobile and Embedded DevicesQi -- Lightweight Boot Loader Applied in Mobile and Embedded Devices
Qi -- Lightweight Boot Loader Applied in Mobile and Embedded DevicesNational Cheng Kung University
4.6K views39 slides
nl80211 and libnl by
nl80211 and libnlnl80211 and libnl
nl80211 and libnlawkman
4K views9 slides
Debian & the BeagleBone Black by
Debian & the BeagleBone BlackDebian & the BeagleBone Black
Debian & the BeagleBone BlackRaju Vindane
971 views29 slides
COS: A Configurable OS for Embedded SoC Systems by
COS: A Configurable OS for Embedded SoC SystemsCOS: A Configurable OS for Embedded SoC Systems
COS: A Configurable OS for Embedded SoC SystemsPrateek Anand
714 views15 slides
Connecting Hardware to the Web with the BeagleBone by
Connecting Hardware to the Web with the BeagleBoneConnecting Hardware to the Web with the BeagleBone
Connecting Hardware to the Web with the BeagleBoneFrank Hunleth
3.8K views13 slides
BeagleBone Workshop by
BeagleBone WorkshopBeagleBone Workshop
BeagleBone WorkshopChirag Nagpal
3.9K views16 slides
Beagle board by
Beagle boardBeagle board
Beagle boardKondaveeti Arun Gopal
3.9K views29 slides
Android power management by
Android power managementAndroid power management
Android power managementJerrin George
47.2K views50 slides
BeagleBone Black Using Python by
BeagleBone Black Using PythonBeagleBone Black Using Python
BeagleBone Black Using PythonSai Viswanath
9.1K views27 slides
Accessing Hardware on Android by
Accessing Hardware on AndroidAccessing Hardware on Android
Accessing Hardware on AndroidGary Bisson
18.4K views50 slides
Tuning Android for low RAM by
Tuning Android for low RAMTuning Android for low RAM
Tuning Android for low RAMChris Simmonds
13.1K views35 slides

Viewers also liked (20)

Hardware Abstraction Layer by Teh Kian Cheng
Hardware Abstraction LayerHardware Abstraction Layer
Hardware Abstraction Layer
Teh Kian Cheng2.2K views
Diving inside Android Wifi by Nanik Tolaram
Diving inside Android WifiDiving inside Android Wifi
Diving inside Android Wifi
Nanik Tolaram905 views
HKG15-409: ARM Hibernation enablement on SoCs - a case study by Linaro
HKG15-409: ARM Hibernation enablement on SoCs - a case studyHKG15-409: ARM Hibernation enablement on SoCs - a case study
HKG15-409: ARM Hibernation enablement on SoCs - a case study
Linaro5.3K views
Android HAL Introduction: libhardware and its legacy by Jollen Chen
Android HAL Introduction: libhardware and its legacyAndroid HAL Introduction: libhardware and its legacy
Android HAL Introduction: libhardware and its legacy
Jollen Chen19.5K views
Hibernation in Linux 2.6.29 by Varun Mahajan
Hibernation in Linux 2.6.29Hibernation in Linux 2.6.29
Hibernation in Linux 2.6.29
Varun Mahajan6.8K views
nl80211 and libnl by awkman
nl80211 and libnlnl80211 and libnl
nl80211 and libnl
awkman4K views
Debian & the BeagleBone Black by Raju Vindane
Debian & the BeagleBone BlackDebian & the BeagleBone Black
Debian & the BeagleBone Black
Raju Vindane971 views
COS: A Configurable OS for Embedded SoC Systems by Prateek Anand
COS: A Configurable OS for Embedded SoC SystemsCOS: A Configurable OS for Embedded SoC Systems
COS: A Configurable OS for Embedded SoC Systems
Prateek Anand714 views
Connecting Hardware to the Web with the BeagleBone by Frank Hunleth
Connecting Hardware to the Web with the BeagleBoneConnecting Hardware to the Web with the BeagleBone
Connecting Hardware to the Web with the BeagleBone
Frank Hunleth3.8K views
Android power management by Jerrin George
Android power managementAndroid power management
Android power management
Jerrin George47.2K views
BeagleBone Black Using Python by Sai Viswanath
BeagleBone Black Using PythonBeagleBone Black Using Python
BeagleBone Black Using Python
Sai Viswanath9.1K views
Accessing Hardware on Android by Gary Bisson
Accessing Hardware on AndroidAccessing Hardware on Android
Accessing Hardware on Android
Gary Bisson18.4K views
Tuning Android for low RAM by Chris Simmonds
Tuning Android for low RAMTuning Android for low RAM
Tuning Android for low RAM
Chris Simmonds13.1K views

Similar to Android Boot Time Optimization

Rloader, alternative tech to achieve fast boot time for ARM Linux by
Rloader, alternative tech to achieve fast boot time for ARM LinuxRloader, alternative tech to achieve fast boot time for ARM Linux
Rloader, alternative tech to achieve fast boot time for ARM Linuxmatt_hsu
2.4K views34 slides
Fast boot by
Fast bootFast boot
Fast bootSZ Lin
3.9K views40 slides
HKG18-TR14 - Postmortem Debugging with Coresight by
HKG18-TR14 - Postmortem Debugging with CoresightHKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with CoresightLinaro
560 views19 slides
Labs_BT_20221017.pptx by
Labs_BT_20221017.pptxLabs_BT_20221017.pptx
Labs_BT_20221017.pptxssuserb4d806
96 views270 slides
Kernel debug log and console on openSUSE by
Kernel debug log and console on openSUSEKernel debug log and console on openSUSE
Kernel debug log and console on openSUSESUSE Labs Taipei
2K views34 slides
Kernel Recipes 2015 - Kernel dump analysis by
Kernel Recipes 2015 - Kernel dump analysisKernel Recipes 2015 - Kernel dump analysis
Kernel Recipes 2015 - Kernel dump analysisAnne Nicolas
2.5K views25 slides
Containers with systemd-nspawn by
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawnGábor Nyers
5.5K views27 slides
Linux kernel tracing superpowers in the cloud by
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudAndrea Righi
401 views36 slides
Renesas DevCon 2010: Starting a QT Application with Minimal Boot by
Renesas DevCon 2010: Starting a QT Application with Minimal BootRenesas DevCon 2010: Starting a QT Application with Minimal Boot
Renesas DevCon 2010: Starting a QT Application with Minimal Bootandrewmurraympc
1.7K views47 slides
Android porting for dummies @droidconin 2011 by
Android porting for dummies @droidconin 2011Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011pundiramit
5.5K views27 slides
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ... by
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...confluent
2.6K views40 slides
Best Practices for performance evaluation and diagnosis of Java Applications ... by
Best Practices for performance evaluation and diagnosis of Java Applications ...Best Practices for performance evaluation and diagnosis of Java Applications ...
Best Practices for performance evaluation and diagnosis of Java Applications ...IndicThreads
2.7K views42 slides
YOW2020 Linux Systems Performance by
YOW2020 Linux Systems PerformanceYOW2020 Linux Systems Performance
YOW2020 Linux Systems PerformanceBrendan Gregg
1.9K views64 slides
Kernel Debugging & Profiling by
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & ProfilingAnil Kumar Pugalia
18.8K views14 slides
Ch04 system administration by
Ch04 system administration Ch04 system administration
Ch04 system administration Raja Waseem Akhtar
842 views26 slides
Ch04 by
Ch04Ch04
Ch04Raja Waseem Akhtar
828 views26 slides
Container Performance Analysis Brendan Gregg, Netflix by
Container Performance Analysis Brendan Gregg, NetflixContainer Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, NetflixDocker, Inc.
12.6K views75 slides
Early Software Development through Palladium Emulation by
Early Software Development through Palladium EmulationEarly Software Development through Palladium Emulation
Early Software Development through Palladium EmulationRaghav Nayak
578 views29 slides
Container Performance Analysis by
Container Performance AnalysisContainer Performance Analysis
Container Performance AnalysisBrendan Gregg
448.6K views75 slides
Auditing the Opensource Kernels by
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource KernelsSilvio Cesare
888 views81 slides

Similar to Android Boot Time Optimization (20)

Rloader, alternative tech to achieve fast boot time for ARM Linux by matt_hsu
Rloader, alternative tech to achieve fast boot time for ARM LinuxRloader, alternative tech to achieve fast boot time for ARM Linux
Rloader, alternative tech to achieve fast boot time for ARM Linux
matt_hsu2.4K views
Fast boot by SZ Lin
Fast bootFast boot
Fast boot
SZ Lin3.9K views
HKG18-TR14 - Postmortem Debugging with Coresight by Linaro
HKG18-TR14 - Postmortem Debugging with CoresightHKG18-TR14 - Postmortem Debugging with Coresight
HKG18-TR14 - Postmortem Debugging with Coresight
Linaro560 views
Kernel debug log and console on openSUSE by SUSE Labs Taipei
Kernel debug log and console on openSUSEKernel debug log and console on openSUSE
Kernel debug log and console on openSUSE
SUSE Labs Taipei2K views
Kernel Recipes 2015 - Kernel dump analysis by Anne Nicolas
Kernel Recipes 2015 - Kernel dump analysisKernel Recipes 2015 - Kernel dump analysis
Kernel Recipes 2015 - Kernel dump analysis
Anne Nicolas2.5K views
Containers with systemd-nspawn by Gábor Nyers
Containers with systemd-nspawnContainers with systemd-nspawn
Containers with systemd-nspawn
Gábor Nyers5.5K views
Linux kernel tracing superpowers in the cloud by Andrea Righi
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloud
Andrea Righi401 views
Renesas DevCon 2010: Starting a QT Application with Minimal Boot by andrewmurraympc
Renesas DevCon 2010: Starting a QT Application with Minimal BootRenesas DevCon 2010: Starting a QT Application with Minimal Boot
Renesas DevCon 2010: Starting a QT Application with Minimal Boot
andrewmurraympc1.7K views
Android porting for dummies @droidconin 2011 by pundiramit
Android porting for dummies @droidconin 2011Android porting for dummies @droidconin 2011
Android porting for dummies @droidconin 2011
pundiramit5.5K views
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ... by confluent
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...
Kafka Summit SF 2017 - One Day, One Data Hub, 100 Billion Messages: Kafka at ...
confluent2.6K views
Best Practices for performance evaluation and diagnosis of Java Applications ... by IndicThreads
Best Practices for performance evaluation and diagnosis of Java Applications ...Best Practices for performance evaluation and diagnosis of Java Applications ...
Best Practices for performance evaluation and diagnosis of Java Applications ...
IndicThreads2.7K views
YOW2020 Linux Systems Performance by Brendan Gregg
YOW2020 Linux Systems PerformanceYOW2020 Linux Systems Performance
YOW2020 Linux Systems Performance
Brendan Gregg1.9K views
Container Performance Analysis Brendan Gregg, Netflix by Docker, Inc.
Container Performance Analysis Brendan Gregg, NetflixContainer Performance Analysis Brendan Gregg, Netflix
Container Performance Analysis Brendan Gregg, Netflix
Docker, Inc.12.6K views
Early Software Development through Palladium Emulation by Raghav Nayak
Early Software Development through Palladium EmulationEarly Software Development through Palladium Emulation
Early Software Development through Palladium Emulation
Raghav Nayak578 views
Container Performance Analysis by Brendan Gregg
Container Performance AnalysisContainer Performance Analysis
Container Performance Analysis
Brendan Gregg448.6K views
Auditing the Opensource Kernels by Silvio Cesare
Auditing the Opensource KernelsAuditing the Opensource Kernels
Auditing the Opensource Kernels
Silvio Cesare888 views

Recently uploaded

Can Santa Cloud survive the Generative AI revolution? by
Can Santa Cloud survive the Generative AI revolution?Can Santa Cloud survive the Generative AI revolution?
Can Santa Cloud survive the Generative AI revolution?Lorenzo Barbieri
17 views19 slides
論文紹介:Discovering Universal Geometry in Embeddings with ICA by
論文紹介:Discovering Universal Geometry in Embeddings with ICA論文紹介:Discovering Universal Geometry in Embeddings with ICA
論文紹介:Discovering Universal Geometry in Embeddings with ICAToru Tamaki
22 views17 slides
GDSC VJIT Solution Challenge 2024 Info Session.pptx by
GDSC VJIT Solution Challenge 2024 Info Session.pptxGDSC VJIT Solution Challenge 2024 Info Session.pptx
GDSC VJIT Solution Challenge 2024 Info Session.pptxBharath887486
14 views32 slides
Linux Basics by
Linux BasicsLinux Basics
Linux BasicsLokesh C
10 views22 slides
Agile Kolkata 2023 I EEBO Metrics in the Times of GenAI - Dinker Charak by
Agile Kolkata 2023 I EEBO Metrics in the Times of GenAI - Dinker CharakAgile Kolkata 2023 I EEBO Metrics in the Times of GenAI - Dinker Charak
Agile Kolkata 2023 I EEBO Metrics in the Times of GenAI - Dinker CharakAgileNetwork
8 views25 slides
Java 21 and Beyond-A Roadmap of Innovations by
Java 21 and Beyond-A Roadmap of InnovationsJava 21 and Beyond-A Roadmap of Innovations
Java 21 and Beyond-A Roadmap of InnovationsAna-Maria Mihalceanu
78 views81 slides
11 BOLD PREDICTIONS FOR THE MEDIA AND ENTERTAINMENT INDUSTRY IN 2024 by
11 BOLD PREDICTIONS FOR THE MEDIA AND ENTERTAINMENT INDUSTRY IN 202411 BOLD PREDICTIONS FOR THE MEDIA AND ENTERTAINMENT INDUSTRY IN 2024
11 BOLD PREDICTIONS FOR THE MEDIA AND ENTERTAINMENT INDUSTRY IN 2024Liveplex
12 views14 slides
Security Human Factor Sustainable Outputs: The Network eAcademy by
Security Human Factor Sustainable Outputs: The Network eAcademySecurity Human Factor Sustainable Outputs: The Network eAcademy
Security Human Factor Sustainable Outputs: The Network eAcademyCSUC - Consorci de Serveis Universitaris de Catalunya
52 views26 slides
The Role of Gas Analyzers in Carbon Neutrality Goals by
The Role of Gas Analyzers in Carbon Neutrality GoalsThe Role of Gas Analyzers in Carbon Neutrality Goals
The Role of Gas Analyzers in Carbon Neutrality GoalsEnviro Solutions Technology
11 views6 slides
The Digital Transformation of Education: A Hyper-Disruptive Era through Block... by
The Digital Transformation of Education: A Hyper-Disruptive Era through Block...The Digital Transformation of Education: A Hyper-Disruptive Era through Block...
The Digital Transformation of Education: A Hyper-Disruptive Era through Block...Förderverein Technische Fakultät
78 views218 slides
Connector Corner: Power your campaign with Mailchimp, Microsoft Teams, CRM an... by
Connector Corner: Power your campaign with Mailchimp, Microsoft Teams, CRM an...Connector Corner: Power your campaign with Mailchimp, Microsoft Teams, CRM an...
Connector Corner: Power your campaign with Mailchimp, Microsoft Teams, CRM an...DianaGray10
59 views12 slides
One day informatics AI design.pdf by
One day informatics AI design.pdfOne day informatics AI design.pdf
One day informatics AI design.pdflombokdscindonesia
13 views65 slides
Where To Find Spare Change in your AWS Couch Cushions.pptx by
Where To Find Spare Change in your AWS Couch Cushions.pptxWhere To Find Spare Change in your AWS Couch Cushions.pptx
Where To Find Spare Change in your AWS Couch Cushions.pptxkarlkatzke
18 views20 slides
DevFest Taipei - Advanced Ticketing System.pdf by
DevFest Taipei - Advanced Ticketing System.pdfDevFest Taipei - Advanced Ticketing System.pdf
DevFest Taipei - Advanced Ticketing System.pdfMichael Chi
86 views35 slides
Switch to Svelte | GDSC NIT Silchar | Speaker Session | SvelteKit by
Switch to Svelte | GDSC NIT Silchar | Speaker Session | SvelteKitSwitch to Svelte | GDSC NIT Silchar | Speaker Session | SvelteKit
Switch to Svelte | GDSC NIT Silchar | Speaker Session | SvelteKitGoogle Developer Students Club NIT Silchar
36 views15 slides
AI in pharmacy: Revolutionizing Healthcare by
AI in pharmacy: Revolutionizing HealthcareAI in pharmacy: Revolutionizing Healthcare
AI in pharmacy: Revolutionizing HealthcareDarvan Shvan
18 views32 slides
A Rift in Space.pdf by
A Rift in Space.pdfA Rift in Space.pdf
A Rift in Space.pdfehclark63
19 views27 slides
Future-Proof Your SAP® Processes with Mass Data Automation by
Future-Proof Your SAP® Processes with Mass Data AutomationFuture-Proof Your SAP® Processes with Mass Data Automation
Future-Proof Your SAP® Processes with Mass Data Automationredmondpulver
14 views23 slides
Presentation Popup Haiti IOM mission Knowledge Management System by
Presentation Popup Haiti IOM mission Knowledge Management SystemPresentation Popup Haiti IOM mission Knowledge Management System
Presentation Popup Haiti IOM mission Knowledge Management SystemSafari Mupe
2.5K views6 slides
API testing Beyond the Basics AI & Automation Techniques by
API testing Beyond the Basics AI & Automation TechniquesAPI testing Beyond the Basics AI & Automation Techniques
API testing Beyond the Basics AI & Automation TechniquesPostman
14 views19 slides

Recently uploaded (20)

Can Santa Cloud survive the Generative AI revolution? by Lorenzo Barbieri
Can Santa Cloud survive the Generative AI revolution?Can Santa Cloud survive the Generative AI revolution?
Can Santa Cloud survive the Generative AI revolution?
Lorenzo Barbieri17 views
論文紹介:Discovering Universal Geometry in Embeddings with ICA by Toru Tamaki
論文紹介:Discovering Universal Geometry in Embeddings with ICA論文紹介:Discovering Universal Geometry in Embeddings with ICA
論文紹介:Discovering Universal Geometry in Embeddings with ICA
Toru Tamaki22 views
GDSC VJIT Solution Challenge 2024 Info Session.pptx by Bharath887486
GDSC VJIT Solution Challenge 2024 Info Session.pptxGDSC VJIT Solution Challenge 2024 Info Session.pptx
GDSC VJIT Solution Challenge 2024 Info Session.pptx
Bharath88748614 views
Linux Basics by Lokesh C
Linux BasicsLinux Basics
Linux Basics
Lokesh C10 views
Agile Kolkata 2023 I EEBO Metrics in the Times of GenAI - Dinker Charak by AgileNetwork
Agile Kolkata 2023 I EEBO Metrics in the Times of GenAI - Dinker CharakAgile Kolkata 2023 I EEBO Metrics in the Times of GenAI - Dinker Charak
Agile Kolkata 2023 I EEBO Metrics in the Times of GenAI - Dinker Charak
AgileNetwork8 views
11 BOLD PREDICTIONS FOR THE MEDIA AND ENTERTAINMENT INDUSTRY IN 2024 by Liveplex
11 BOLD PREDICTIONS FOR THE MEDIA AND ENTERTAINMENT INDUSTRY IN 202411 BOLD PREDICTIONS FOR THE MEDIA AND ENTERTAINMENT INDUSTRY IN 2024
11 BOLD PREDICTIONS FOR THE MEDIA AND ENTERTAINMENT INDUSTRY IN 2024
Liveplex12 views
Connector Corner: Power your campaign with Mailchimp, Microsoft Teams, CRM an... by DianaGray10
Connector Corner: Power your campaign with Mailchimp, Microsoft Teams, CRM an...Connector Corner: Power your campaign with Mailchimp, Microsoft Teams, CRM an...
Connector Corner: Power your campaign with Mailchimp, Microsoft Teams, CRM an...
DianaGray1059 views
Where To Find Spare Change in your AWS Couch Cushions.pptx by karlkatzke
Where To Find Spare Change in your AWS Couch Cushions.pptxWhere To Find Spare Change in your AWS Couch Cushions.pptx
Where To Find Spare Change in your AWS Couch Cushions.pptx
karlkatzke18 views
DevFest Taipei - Advanced Ticketing System.pdf by Michael Chi
DevFest Taipei - Advanced Ticketing System.pdfDevFest Taipei - Advanced Ticketing System.pdf
DevFest Taipei - Advanced Ticketing System.pdf
Michael Chi86 views
AI in pharmacy: Revolutionizing Healthcare by Darvan Shvan
AI in pharmacy: Revolutionizing HealthcareAI in pharmacy: Revolutionizing Healthcare
AI in pharmacy: Revolutionizing Healthcare
Darvan Shvan18 views
A Rift in Space.pdf by ehclark63
A Rift in Space.pdfA Rift in Space.pdf
A Rift in Space.pdf
ehclark6319 views
Future-Proof Your SAP® Processes with Mass Data Automation by redmondpulver
Future-Proof Your SAP® Processes with Mass Data AutomationFuture-Proof Your SAP® Processes with Mass Data Automation
Future-Proof Your SAP® Processes with Mass Data Automation
redmondpulver14 views
Presentation Popup Haiti IOM mission Knowledge Management System by Safari Mupe
Presentation Popup Haiti IOM mission Knowledge Management SystemPresentation Popup Haiti IOM mission Knowledge Management System
Presentation Popup Haiti IOM mission Knowledge Management System
Safari Mupe2.5K views
API testing Beyond the Basics AI & Automation Techniques by Postman
API testing Beyond the Basics AI & Automation TechniquesAPI testing Beyond the Basics AI & Automation Techniques
API testing Beyond the Basics AI & Automation Techniques
Postman14 views

Android Boot Time Optimization

  • 1. Connect your device to application
  • 2. Android Boot Time Optimization Kan-Ru Chen kanru@0xlab.org Sep 09, 2011
  • 3. Agenda Motivation Boot Time Measurement Android Boot Time Analysis Reduction Approach Hibernation Based Technologies We Don't Need Boot-loader Demo Future Work and Conclusions
  • 7. Printk Times Linux kernel feature Built-in since Linux 2.6.11 How to enable?  Add CONFIG_PRINTK_TIME=y to .config  Or choose from menuconfig Kernel hacking ---> [*] Show timing information on printks
  • 8. Printk Times Output Example linux$ dmesg [0.000000] per task-struct memory footprint: 1152 bytes [0.003692] Calibrating delay loop... 506.27 BogoMIPS (lpj=1978368) [0.079833] pid_max: default: 32768 minimum: 301 [0.080230] Security Framework initialized [0.080474] Mount-cache hash table entries: 512 [0.083892] CPU: Testing write buffer coherency: ok Analysis Tool linux$ dmesg > timefile linux$ scripts/show_delta timefile ... [0.194488 < 0.194488 >] OMAP DMA hardware revision 5.0 [0.259948 < 0.065460 >] bio: create slab <bio-0> at 0 [0.267822 < 0.007874 >] SCSI subsystem initialized ...
  • 9. initcall_debug Kernel Parameter Print the time spent for each initcall Output Example calling ipc_init+0x0/0x28 @ 1 msgmni has been set to 42 initcall ipc_init+0x0/0x28 returned 0 after 1872 usecs
  • 10. Bootchart Visualize the booting process Use “bootchartd” to collect CPU and IO utilization information. On Ubuntu: apt-get install bootchart bootchart-view Original “bootchartd” is not suitable for embedded usage.
  • 12. Strace Trace system calls during process execution and output timing information. $ strace -tt ls 15:11:04.243357 execve("/bin/ls", ["ls"], [/* 51 vars */]) = 0 15:11:04.244252 brk(0) = 0x234f000 15:11:04.244458 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT 15:11:04.244676 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE| MAP_ANONYMOUS, -1, 0) = 0x7f1444794000 15:11:04.244852 access("/etc/ld.so.preload", R_OK) = -1 ENOENT 15:11:04.245096 open("/etc/ld.so.cache", O_RDONLY) = 3
  • 13. OProfile OProfile is a system-wide profiler for Linux systems. Capable of profiling all running code at low overhead. Supports wide number of hardwares. Profiling daemon ported to Android and available in AOSP.
  • 14. OProfile Output Example $ opreport --exclude-dependent CPU: PIII, speed 863.195 MHz (estimated) Counted CPU_CLK_UNHALTED events (clocks processor is not halted)... 450385 75.6634 cc1plus 60213 10.1156 lyx 29313 4.9245 XFree86 11633 1.9543 as 10204 1.7142 oprofiled 7289 1.2245 vmlinux 7066 1.1871 bash 6417 1.0780 oprofile 6397 1.0747 vim ...
  • 15. Perf New profiling tool based on the performance counter subsystem of Linux. Very powerful and easy to use. Included in Linux source code: tools/perf/
  • 16. Perf Recording: $ perf record -a -f ^C [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.288 MB perf.data (~12567 samples)] Output $ perf report --sort comm,dso,symbol|head -10 # Events: 1K cycles # # Overhead Command Shared Object Symbol # ........ ........... ...................... ............ # 35.47% firefox libxul.so [.] 0xc1b3a7 3.08% firefox libcairo.so.2.11000.2 [.] 0xff88 2.98% Xorg Xorg (deleted) [.] 0xe201c 2.51% firefox firefox [.] 0x2726 1.49% Xorg [kernel.kallsyms] [k] find_vma 0.93% perf_3.0.0 perf_3.0.0 [.] hex2u64
  • 17. Perf Timechart $ perf timechart record $ perf timechart
  • 19. Bootchart Original “bootchartd” is not suitable on embedded devices. Android re-implemented in its “init” program.
  • 20. Bootchart To build: $ cd system/core/init $ touch init.c $ mm INIT_BOOTCHART=true
  • 21. Bootchart To run: $ adb shell 'echo 120 > /data/bootchart-start' Remember the /data directory must be write able during boot. Use grab-bootchart.sh to retrieve the data.
  • 22. Strace After analyzed the bootchart, can use strace to analyze individual progarm. Available in AOSP since Éclair
  • 23. Strace Modify init.rc from service zygote /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server To service zygote /system/xbin/strace -tt -o/data/boot.strace /system/bin/app_process -Xzygote /system/bin --zygote --start-system-server
  • 24. Logcat Android log utility Can output timing information Adjust loglevel to 6 in init.rc  Displays time spent for each command
  • 25. Dalvik Method Tracer Method tracer is built into Dalvik Use DDMS or using calls inside source to collect data. // start tracing to "/sdcard/calc.trace" Debug.startMethodTracing("calc"); // ... // stop tracing Debug.stopMethodTracing();
  • 26. Stopwatch Not real stopwatch A utility in Android Framework for measuring C++ code. Output result to system log #include <utils/StopWatch.h> … { StopWatch watch("blah"); /* your codes here */ }
  • 27. Q&A
  • 28. Android Boot Time Analysis
  • 29. Boot-loader Init Usually constant time Avoid init hardware multiple times Ensure to use maximum CPU frequency Use faster NAND/MMC reading mechanism
  • 30. Kernel Init Mostly usual suspects  ip_auto_config  USB init  Flash driver initialization Fullow the standard Kernel optimizing guide:  http://elinux.org/Boot_Time Avoid loading unneeded kernel module at boot time
  • 31. Zygote Class Preloading Android Framework has thousands of Java classes Preloaded by Zygote and instantiated in its heap To improve Application startup time and save memory Controlled by resource: preloaded-classes  frameworks/base/preloaded-classes
  • 32. Zygote Class Preloading Can use the tool in framework to adjust the list: $ adb logcat > logcat.txt $ java -p preload.jar Compile logcat.txt logcat.compiled $ java -p preload.jar PrintCsv logcat.compiled Google Android Developer Dianne Hackborn said:  The content of the file is a “black art”  You can adjust this as much as you like  But the result maybe suboptimal
  • 33. PackageManager Package Scannig Every APK is scanned at boot time Package management code is inefficient Uses mmaped files means each access will cause page fault ParseZipArchive() scans entire APK for only one AndroidManifest.xml file
  • 34. System Services Starting Last stage of Android boot Start every base service Zygote start SystemServer process Start native service (SurfaceFlinger, AudioFlinger) first Start each service sequentially
  • 35. Q&A
  • 37. Boot-loader Improve U-Boot  Reading multi-mmc-block  Cache (I/D) enablement  Optimize CRC32  Disable verification
  • 38. Boot-loader Qi Boot-loader Qi U-Boot + XLoader Boot-oader Size ~30K ~270K+20K  Only one stage boot-loader Time to Kernel <1s > 5s  Small footprint ~30K Usage Product Engineering Code Simple Complicated  Currently support − iMX31 − Samsung 24xx − Beagleboard  KISS concept − Boot device and load kernel
  • 39. Kernel Boot Time Fullow the standard Kernel optimizing guide:  http://elinux.org/Boot_Time Minimize kernel size Use compression or not Enable embedded options Avoid loading unneeded kernel module at boot time
  • 40. Optimize Android Init Parallize init tasks  insmod cannot be parallized  Use external scripts to init at background Start services on demand
  • 41. Optimize Class Preloading Trade-off between preload class and application startup time Split class to more packages to reduce dependency Save inited heap for later use Share heaps between zygote and children
  • 42. Filesystem Optimization According to reasearch by Linaro Kernel WG Use correct NAND configuration will improve the performance MMC controllers are often optimized for particular usage / filesystem Adjust the filesystem partition scheme
  • 43. Toothpaste Effect Observed by Sony Developer Tim Bird “When you squeeze a tube of toothpaste, sometimes it just moves the toothpaste somewhere else in the tube, and nothing actually comes out.”
  • 44. Q&A
  • 46. QuickBoot Developed by Japanese company Ubiquitous Demand loading of required page from flash Requires deep integration of hardware and software
  • 47. Fast-On Developed by CCU Based on existing technologies thus requires little modification to userspace Release clean-pages before suspend Swap out dirty-pages before save image Image size reduced leads to faster resume time.
  • 49. TuxOnIce Patch TuxOnIce (was Software Suspend 2) is a hibernation patchset Can save images to different locations Can use different compresion algorithm Porting to ARM is possible
  • 50. Android Wakelocks An aggressive approach to save device power Use wakelocks to prevent device going suspend Port TOI to Android have to deal with wakelocks because MMC driver might hold a wakelock
  • 51. Linux Suspend Architecture Documentation/power/devices.txt: struct dev_pm_ops { int (*prepare)(struct device *dev); void (*complete)(struct device *dev); int (*suspend)(struct device *dev); int (*resume)(struct device *dev); int (*freeze)(struct device *dev); int (*thaw)(struct device *dev); int (*poweroff)(struct device *dev); int (*restore)(struct device *dev); int (*suspend_noirq)(struct device *dev); int (*resume_noirq)(struct device *dev); int (*freeze_noirq)(struct device *dev); int (*thaw_noirq)(struct device *dev); int (*poweroff_noirq)(struct device *dev); int (*restore_noirq)(struct device *dev); int (*runtime_suspend)(struct device *dev); int (*runtime_resume)(struct device *dev); int (*runtime_idle)(struct device *dev); };
  • 52. Q&A
  • 53. We Don't Need Boot-loader
  • 54. R-Loader Normal suspend-to-disk approach has many duplicated effort  Boot-loader inits some hardwares  Boot-loader loads the normal kernel image  Kernel inits some hardwares again  Kernel loads the suspended kernel image  Kernel resumes, inits some hardwares again
  • 55. R-Loader 0xlab Developer Matt Proposed “Resume-Loader” R-Loader inits some hardware then reads the suspended kernel image as fast as possible Jump directly to the resume point Kernel will takeover the job and inits reset hardwares
  • 56. Demo Get 0xdroid 0x7 release  https://code.google.com/p/0xdroid/wiki/0x7_leb_gingerbread Get TOI Patch for 0x7 release  https://gitorious.org/0xlab-kernel/kernel/commits/toi/linaro-android.38
  • 57. Future Work and Conclusions Save the heap image (like core dump) of Zygote after preloading classes Modify Dalvik to make hibernation image after system init and before Launcher startup Parallize Android init Cache & Share JITed code fragment
  • 58. Q&A