Difference between revisions of "Improving Android Boot Time"

From eLinux.org
Jump to: navigation, search
(save outline)
 
m (Presentation)
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
This page has notes and materials in support of Tim Bird's presentation "Improving Android Bootup Time",
 
This page has notes and materials in support of Tim Bird's presentation "Improving Android Bootup Time",
which he is gave at [http://events.linuxfoundation.org/events/linuxcon LinuxCon North America, 2010].
+
which he gave at [http://events.linuxfoundation.org/events/linuxcon LinuxCon North America, 2010].
  
 
== Abstract ==
 
== Abstract ==
 
Android is a relatively new distribution of Linux, with a completely different user space implementation, compared to desktop or enterprise Linux. It also has some rather horrible boot times. But it's popular - so Tim decided to take a look and see if the bootup time of a standard Android system could be improved. This presentation describes how well he succeeded in this venture. Tim will present methods of measuring kernel and user-space bootup time on an Android system, as well as present some ideas for places where Android bootup time could be improved.
 
Android is a relatively new distribution of Linux, with a completely different user space implementation, compared to desktop or enterprise Linux. It also has some rather horrible boot times. But it's popular - so Tim decided to take a look and see if the bootup time of a standard Android system could be improved. This presentation describes how well he succeeded in this venture. Tim will present methods of measuring kernel and user-space bootup time on an Android system, as well as present some ideas for places where Android bootup time could be improved.
 +
 +
== Presentation ==
 +
Here's the final presentation which was given at LinuxCon North America, August 2010:
 +
* [[Media:Android-bootup-time-linuxcon-2010-08.pdf|Android-bootup-time-linuxcon-2010-08.pdf]]
  
 
== Outline ==
 
== Outline ==
* Title
+
See [[Improving Android Boot Time Outline]]
* Outline
+
 
** Android boot overview
+
 
** Measuring boot times
+
== Raw Data ==
** Problem areas
+
[''Still need to post my raw data here'']
*** Some gory details
+
 
** Ideas for improvements
+
== Resources ==
* Android boot overview
+
=== logdelta ===
** bootloader
+
Here is the 'logdelta' program, which can be used to see the time between logcat lines.  Using logcat,
** kernel
+
grep, and logdelta, you can usually figure out how long certain operations are taking, based on the log
** init
+
timestamps.
** zygote
+
* [[Media:Logdelta.txt]] - the logdelta program
*** building preload heap
+
** ''Note: I had to give the program a .txt extension, in order to upload it to the elinux wiki. When you download it, rename it and make it executable with''
*** start package manager
+
*** mv Logdelta.txt logdelta; chmod a+x logdelta
** service manager
+
 
*** start services
+
=== instrumentation patches ===
* measuring bootup time
+
Here is a patch which instruments the class preloading and the package scanning, to give more verbose
** systems measured: adp1, n1, evm
+
output during these phases of the bootup.  Note that these will make booting much more verbose, which
*** adp1 with donut
+
will very likely overrun your logcat buffers. So you may need to grab the data with the 'logcat'
*** n1 with eclair
+
command soon after the operation you are interested in occurs.
*** evm with eclair
+
* [[Media:Android-boot-instrumentation.patch]]
**** NOTE: used nfs root filesystem (file IO timings might be bogus)
+
 
* Tools for measuring and tracing boot time
+
=== parseZipArchive patch ===
** stopwatch
+
This patch removes the per-file signature check in parseZipArchive().  It also adds some logging to show
** grabserial
+
how long the open operation is taking, in ZipFileRO::open
** printk times
+
 
** bootchart
+
These routines are in the source file: frameworks/base/libs/utils/ZipFileRO.cpp
** strace
+
 
** logcat
+
* [[Media:parseZipArchive-no-sig-check.patch]]
** method tracer*
 
** ftrace*
 
* stopwatch
 
* grabserial
 
* printk times
 
* bootchart
 
* strace
 
* logcat
 
** extra instrumentation for preloading classes
 
** PARSE_CHATTY flag for package scanning
 
** mention my own tool 'logdelta'
 
* method tracer*
 
** method traces is built in to  
 
** ftrace?? (no)
 
* Problem Areas
 
** First, a bootchart for EVM board
 
** bootloader init
 
** kernel init
 
** zygote class preloading
 
** package scanning
 
** service initialization
 
* bootloader init
 
** outside scope of this talk
 
** didn't measure commercial bootloader, only development one (U-boot)
 
* kernel init
 
** is mostly the usual suspects
 
** (initcall_debug results)
 
** USB
 
* zygote class preloading
 
** zygote pre-loads just under 2000 classes, and instantiates them in its heap
 
** controlled by file:
 
* package manager package scan
 
** exact purpose is not known
 
*** validation of certificates, permissions, capabilities and dependencies, etc.?
 
** EVERY package is scanned at boot time
 
* ideas for enhancements
 
** kernel speedups
 
** optimize package scan
 
** optimize class preloading
 
** miscellaneous optimizations
 
** sreadahead??
 
* kernel speedups
 
** outside the scope of this presentation
 
** see http://elinux.org/Boot_Time
 
* optimize package scan
 
*** most definitely
 
*** need to continue analysis
 
**** most likely, should switch to a compressed flash file system
 
** use pre-constructed dalvik heap? (difficult?)
 
*** thread the heap construction?
 
* sreadahead??
 
** could use sreadahead to pre-fill page cache
 
** however, this just masks bad behavior
 
*** Contacts.apk (half of 1.6M) is read 4 times! during boot
 
*** filling page cache makes reads after first one fast, but it would be better to avoid all these reads altogether
 
**** better to just optimize or eliminate parseZipArchive()
 
** sreadahead should be used dead last (after all other enhancements)
 
  
      - don't know how to preconstruct heap
+
[[Category:Android]]
      - need to analyze heap
+
[[Category:Boot Time]]
        - FIXTHIS - is heap identical on every boot?
 
          - how to dump heap memory
 
          - how to dump any memory in Android??
 
        - are parts identical??
 
    - zoneinfo inefficiencies
 
        - measure without strace, and see if time is a problem
 
  - remaining questions
 
    - future directions
 

Latest revision as of 11:24, 13 January 2011

This page has notes and materials in support of Tim Bird's presentation "Improving Android Bootup Time", which he gave at LinuxCon North America, 2010.

Abstract

Android is a relatively new distribution of Linux, with a completely different user space implementation, compared to desktop or enterprise Linux. It also has some rather horrible boot times. But it's popular - so Tim decided to take a look and see if the bootup time of a standard Android system could be improved. This presentation describes how well he succeeded in this venture. Tim will present methods of measuring kernel and user-space bootup time on an Android system, as well as present some ideas for places where Android bootup time could be improved.

Presentation

Here's the final presentation which was given at LinuxCon North America, August 2010:

Outline

See Improving Android Boot Time Outline


Raw Data

[Still need to post my raw data here]

Resources

logdelta

Here is the 'logdelta' program, which can be used to see the time between logcat lines. Using logcat, grep, and logdelta, you can usually figure out how long certain operations are taking, based on the log timestamps.

  • Media:Logdelta.txt - the logdelta program
    • Note: I had to give the program a .txt extension, in order to upload it to the elinux wiki. When you download it, rename it and make it executable with
      • mv Logdelta.txt logdelta; chmod a+x logdelta

instrumentation patches

Here is a patch which instruments the class preloading and the package scanning, to give more verbose output during these phases of the bootup. Note that these will make booting much more verbose, which will very likely overrun your logcat buffers. So you may need to grab the data with the 'logcat' command soon after the operation you are interested in occurs.

parseZipArchive patch

This patch removes the per-file signature check in parseZipArchive(). It also adds some logging to show how long the open operation is taking, in ZipFileRO::open

These routines are in the source file: frameworks/base/libs/utils/ZipFileRO.cpp