Android boot is slow?
My phone has a Quad Core, 3 Gig of RAM ... Android (Both KitKat and Lollipop) takes some 80 seconds to boot to completion.
My phone is only dual core with 1G RAM (Zenfone 4) and I never have that problem. Cold boot in ~60 seconds, reboot in 40-ish (CyannogenMod 12.1).
some users report less than 10 seconds booting time using Ubuntu with systemd and some 20 seconds ...
It depends on the config and what you considered "boot time". My laptop (i5 1st Gen, 4 GB RAM with spinning disk) is considered usable (finished booting) after about 90 seconds. Sure I can delay/disable some of the services to get faster boot time and start them manually as needed. But in my point of view, based on my preference, that won't count as usable.
On PC vs Mobile
There's some differences you should consider when comparing between pc and mobile linux. from CPU down to the kernel. Most notable differences:
- Due to the nature of the device, mobile CPU mostly designed with power conservation as main consideration. This greatly affect performance.
- Android kernel have some mobile-specific features which may affect boot time and hardware i/o access.
- Furthermore, Android kernel known to have compatibility problems with mainline/stable. This is mostly due to vendor's preference to stick with old kernel version that compatible with their device drivers. AOSP Marshmallow runs
3.18.10
while stable kernel is currently at 4.6.2
.
So, what makes Android boot so slow?
Why don't we check? :)
If you have access to adb and already enable Developer Options, check the boot log using
adb logcat -d -b events -v threadtime | grep "boot"
on my device, this is the output:
bambang@pamungkas ~ % adb logcat -d -b events -v threadtime | grep "boot"
06-08 04:35:01.417 193 193 I boot_progress_start: 9906
06-08 04:35:03.718 193 193 I boot_progress_preload_start: 12208
06-08 04:35:07.838 193 193 I boot_progress_preload_end: 16328
06-08 04:35:08.158 513 513 I boot_progress_system_run: 16647
06-08 04:35:09.880 513 513 I boot_progress_pms_start: 18370
06-08 04:35:10.204 513 513 I boot_progress_pms_system_scan_start: 18693
06-08 04:35:24.487 513 513 I boot_progress_pms_data_scan_start: 32977
06-08 04:35:28.552 513 513 I boot_progress_pms_scan_end: 37042
06-08 04:35:28.696 513 513 I boot_progress_pms_ready: 37186
06-08 04:35:33.088 513 513 I boot_progress_ams_ready: 41578
06-08 04:35:40.755 513 533 I boot_progress_enable_screen: 49244
As you can see, total boot time from VM start until initial screen drawing by window manager is ~40 seconds. Additional time on firmware & kernel space (on your linked asnwer, this translate to step 1-4) isn't included.
Notice that it takes ~18 secs to process the entire system's apk (boot_progress_pms_*
), this translate to ~45% of boot time, which includes:
- cleaning inexistent system packages and incomplete installation of packages,
- validating installed apps,
- setting library path,
- etc (see: complete source code of PackageManagerService)
So generally, the total boot time is dependent with the number of packages (app) installed on the device. More app means longer wait during pms process. Additionally, starting activities takes ~5 sec / 20% of boot time. The rest is neither significant nor safely modifiable without deep knowlegde of system behaviors.
Is there anything I can do to speed up the booting process?
- Try other ROM. Sony is one of the "good guys" who provide healthy environment for tweakers. I recommend AOSP or Cyanogen. Just be aware of the limitations
- Test, don't assume! It's easy to make assumption that A boot slow, B is faster. A simple logcat command like above would reveal some useful infos for basic boot time benchmarking between ROMs.
- If you know what you're doing, Embedded Linux Wiki have a list of possible tweaks to improve boot time.
On improving boot time
On your comment
ART was designed to make running apps faster. Who's working on one to make booting faster out of the box?
In my opinion, tweaking boot time is both unnecesarry and provide insignificant gain. Since your phone will, theoretically, stay up most of the time; it's far more important to maintain the system stability (with the tradeoff of longer boot process) to ensure higher uptime and less error.