# AutoFDO profiles for Android common kernels ## Profile Directory Tree This directory contains AutoFDO profiles for Android common kernels. These profiles can be used to optimize kernel builds for specific architectures and kernel versions. Following is the profile directory structure. ```none kernel |-- README.md |-- BUILD.bazel |-- aarch64 | |-- android16-6.12 | | |-- kernel.afdo | | |-- source_info.md | +-- ... +-- ... ``` * `kernel` - The root directory for all AutoFDO profiles. * `README.md` - This file. * `BUILD.bazel` - Bazel build file that exports all profiles. * `/` - A directory containing profiles for a specific architecture (e.g., `aarch64`). * `/` - A directory containing profiles for a specific kernel branch (e.g., `android16-6.12`). * `kernel.afdo` - The AutoFDO profile file. * `source_info.md` - A file containing information about the source code used to generate the profile. ## Performance improvements ### android16-6.12 branch | Benchmark | Improvement | |---|---| | Boot time | 2.1% | | Cold App launch time | 3.1% | | Binder-rpc | 7.8% | | Binder-addints | 30.2% | | Hwbinder | 17.7% | | Bionic (syscall_mmap) | 5.0% | | Bionic (pthread) | 2.4% | | Bionic (stdio) | 3.0% | | Bionic (all) | 1.2% | ## Steps to reproduce the profile A kernel profile is generated by running app crawling and app launching for top 100 apps from Google Play Store. While running, we collect ETM data for the kernel, which records executed instruction stream. Finally, we merge and convert ETM data to one AutoFDO profile. * 1. Build a kernel image and flash it on an Android device * The source code and test device used to generate each profile are listed in `source_info.md`. * We use a Pixel device. But using other real devices should get a similar profile. * 2. Run app crawling and app launching for top 100 apps * Add a gmail account on the test device. Because app crawler can use the account to automatically login some of the apps. * We run app crawler for one app for 3 minutes, and run it twice. App crawler is available at `https://developer.android.com/studio/test/other-testing-tools/app-crawler`. * We run app launching for one app for 3 seconds, and run it 15 times. After each running, the app is killed and cache is cleared. So we get profile for cold app startups. * 3. Record ETM data while running app crawling and app launching. * We use cmdline `simpleperf record -e cs-etm:k -a` to record ETM data for the kernel. A document for collecting and converting ETM data is in `https://android.googlesource.com/platform/system/extras/+/master/simpleperf/doc/collect_etm_data_for_autofdo.md`.