diff --git a/BUILD.bazel b/BUILD.bazel index 3c3c7757503d..bce2e4ff8b04 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -4,7 +4,6 @@ load("@bazel_skylib//lib:paths.bzl", "paths") load("@bazel_skylib//rules:common_settings.bzl", "string_flag") load("@bazel_skylib//rules:write_file.bzl", "write_file") -load("@kernel_toolchain_info//:dict.bzl", "BRANCH") load("@rules_cc//cc:defs.bzl", "cc_library") load("@rules_pkg//pkg:install.bzl", "pkg_install") load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix") @@ -328,7 +327,7 @@ common_kernel( additional_kmi_symbol_lists = [":aarch64_additional_kmi_symbol_lists"], arch = "arm64", build_gki_artifacts = True, - clang_autofdo_profile = "//toolchain/pgo-profiles/kernel:aarch64/" + BRANCH + "/kernel.afdo", + clang_autofdo_profile = ":gki/aarch64/afdo/kernel.afdo", ddk_headers_archive = ":kernel_aarch64_ddk_headers_archive", ddk_module_headers = [":all_headers_aarch64"], defconfig = "arch/arm64/configs/gki_defconfig", diff --git a/gki/README.md b/gki/README.md index 02815c0ddfea..c4dc51432274 100644 --- a/gki/README.md +++ b/gki/README.md @@ -13,7 +13,8 @@ gki | | +-- ... | |-- protected_exports | |-- abi.stg -| +-- abi.stg.allowed_breaks +| |-- abi.stg.allowed_breaks +| +-- afdo +-- ... ``` @@ -35,3 +36,4 @@ architecture. Within each such subdirectory: * e.g. `tools/bazel run //common:kernel_aarch64_abi_update` * `abi.stg.allowed_breaks` - a list of allowed ABI differences * for use by Gerrit ABI monitoring +* `afdo` - [AutoFDO profile for building kernel for the architecture](aarch64/afdo/README.md) diff --git a/gki/aarch64/afdo/README.md b/gki/aarch64/afdo/README.md new file mode 100644 index 000000000000..e77bd6e42bca --- /dev/null +++ b/gki/aarch64/afdo/README.md @@ -0,0 +1,51 @@ + +# AutoFDO profiles for Android common kernels + +This directory contains AutoFDO profiles for Android common kernels. These profiles can be used to +optimize kernel builds for specific architectures and kernel versions. + +## kernel.afdo + +kernel.afdo is an AArch64 kernel profile collected on kernel version 6.12.18 ( +SHA fbd1fef4d7283d210845f8609599efd53c0905a4, build server ID 13287522) using Pixel 6. + +### Performance improvements + +| Benchmark | Improvement | +| --------------------- | ----------- | +| Boot time | 2.6% | +| Cold App launch time | 3.7% | +| Binder-rpc | 9.4% | +| Binder-addints | 31.9% | +| Hwbinder | 16.5% | +| Bionic (syscall_mmap) | 7.1% | +| Bionic (pthread) | 3.3% | +| Bionic (stdio) | 3.7% | +| Bionic (all) | 3.4% | + +Benchmark results were tested on Pixel 6. + +To test a kernel prebuilt with the AutoFDO profile, navigate to [Android build server]( +https://ci.android.com/builds/branches/aosp_kernel-common-android16-6.12/grid) and download +the kernel prebuilts under the `kernel_aarch64_autofdo` target. + +## 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 described above. + * 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](https://developer.android.com/studio/test/other-testing-tools/app-crawler) + for one app for 3 minutes, and run it twice. + * 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](https://android.googlesource.com/platform/system/extras/+/master/simpleperf/doc/collect_etm_data_for_autofdo.md). diff --git a/gki/aarch64/afdo/kernel.afdo b/gki/aarch64/afdo/kernel.afdo new file mode 100644 index 000000000000..b18c17c044d2 Binary files /dev/null and b/gki/aarch64/afdo/kernel.afdo differ