Android Boot Time Optimization

Hughes Systique
3 min readFeb 10, 2021
Android Boot Time Optimization

Google launched Android in 2008 as an operating system for Mobile devices. Since then Android is increasingly being used as an operating system of choice for a variety of devices. Google officially supports mobile, tablet, TV, watch, and Automotive devices however Android is being used in lots of other types of embedded devices including medical devices, toys, infotainment, home gateways, gaming consoles, and so on.

With every new release, Google introduces new features in Android some of those features impacts the boot time of Android devices. Android devices typically take 20 seconds to about a minute to boot. Longer boot time can have a negative impact on user experience. For some of the devices e.g. IVI and medical devices, longer boot time may be problematic.

Boot time for an Android device can be defined as the time between powering on a device to the time when the devices’ home screen is displayed. Android boot process typically involves steps depicted in the diagram below:

Depending on the usages of the device, different strategies may be followed to reduce the boot time. Here are three popular approaches for doing the same:

  • Remove unused services
  • Hibernation
  • Standby mode

The first boot optimization technique involves removing the services/applications that are not needed for the target use case of the device. For example, a gaming console may not need location services, or a smart toy without a screen may not need UI related services. Once redundant services are removed, the boot process can be analyzed using tools like “ boot chart” to identify the critical paths where optimization is needed/possible. Based on this analysis, out of the services that are needed for the device use case, only the essential services/application can be started during boot, the start-up of the rest of the services can be delayed. Processes that hogg CPU/ memory during boot time should be identified and optimized. Something as harmless as boot animation may impact boot time if it consumes more CPU/RAM or it may delay the user’s access to the home screen if animation continues even when the rest of the system is booted. Some of the other possible optimizations are

  1. Starting Zygote as early as possible
  2. Parallel scanning of apk files
  3. In Zygote, loading only the classes essential for Zygote and loading the rest of the classes on demand
  4. Record I/O for processes during boot using Google tools and optimizing process with too much I/O

Hibernation based approach involves saving the system memory and hardware registers snapshot in flash storage at the time of device shutdown and restoring it back to memory on power on.

The Standby mode approach may be used in IVI systems. In this approach, by doing ignition “off”, the device screen and other peripherals are switched off however device may remain powered on. At the time of ignition “on”, the screen and peripherals of the device are switched on giving the impression of quick bootup.

Google has been working on improving the Android boot time. Android provided significant improvement in the timing of the first boot. The following table lists the modifications done by Google and subsequent optimization achieved:

Component: Bootloader

* Saved 1.6s by removing UART log

* Saved 0.4s by changing to LZ4 from GZIP

Component: Device kernel

* Saved 0.3s by removing unused kernel configs and reducing driver size

* Saved 0.3s with dm-verity prefetch optimization

* Saved 0.15s to remove unnecessary wait/test in driver

* Saved 0.12s to remove CONFIG_CC_OPTIMIZE_FOR_SIZE

* Saved 2s on normal boot

* Saved 25s on first boot

* Saved 1.5s by paralleling init commands

* Saved 0.25s by starting zygote early

* Saved 0.22s by cpuset tune

Component: Boot animation

* Started 2s earlier on boot without fsck triggered, much bigger on boot with fsck triggered boot

* Saved 5s on Pixel XL with the immediate shutdown of the boot animation

References:

Originally published at https://hsc.com.

--

--

Hughes Systique

We believe in the transformative powers of digital technologies. Our articles represent our beliefs.