Android boot up performance - systrace

We can use ‘systrace’ to analyze Android boot up performance

0. Read first

https://source.android.com/devices/tech/perf/boot-times#systrace

Following steps have been verified under Android AOSP 9.0.0_r30.

1. Enable systrace:

1.1 /system/etc/init/atrace.rc

$ adb pull /system/etc/init/atrace.rc

Change
write /sys/kernel/debug/tracing/tracing_on 0
->to
write /sys/kernel/debug/tracing/tracing_on 1

add following to atrace.rc:

on property:sys.boot_completed=1
write /d/tracing/tracing_on 0
write /d/tracing/events/ext4/enable 0
write /d/tracing/events/block/enable 0

$ adb push atrace.rc /system/etc/init/atrace.rc

1.2 /system/etc/prop.default

$ adb pull /system/etc/prop.default

change
debug.atrace.tags.enableflags=0
->to
debug.atrace.tags.enableflags=802922

$ adb push prop.default /system/etc/prop.default

1.3 add kernel command line parameters

We can modify bootloader or boot.img to append following parameters

trace_buf_size=64M trace_event=sched_wakeup,sched_switch,sched_blocked_reason,sched_cpu_hotplug

2. Fetch and analyze systrace:

$ git clone https://github.com/catapult-project/catapult.git --depth=10
$ cd catapult
$ adb pull /d/tracing/trace
$ ./trace2html trace