Android: Baseline profile generation #11335
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Here's the documentation for Baseline Profiles
This creates a new benchmark module that is responsible for generating baseline profiles and testing them. As part of this commit, an automatically generated baseline-prof.txt file has been included to speed up launch times with the app in its current state. Later, profile generation can be automated by the buildbot and keep up with the app as it changes.
Currently we only have the ability to generate the profile for activities that are reachable without having games available. The only other way to do this is having a rooted physical device with several manual steps. That is not ideal. Right now profiles are generated using the gradle managed devices feature.
Running this command in the Android directory will download an android device image and run the generate() method in BaselineProfileGenerator.kt
./gradlew :benchmark:pixel2Api31BenchmarkAndroidTest -P android.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=BaselineProfileOnce the build has completed, a profile will be copied into
Android/benchmark/build/outputs/managed_device_android_test_additional_output/pixel2Api31/BaselineProfileGenerator_generate-baseline-prof.txtThis has to be renamed to "baseline-prof.txt" and placed into the "main" folder of the app module.
StartupBenchmark.kt was used to generate the following results (9.85% reduction in startup time!) -
Without baseline profile
min - 939ms
median - 964ms
max - 1006ms
With baseline profile
min - 830ms
median - 869ms
max - 937ms
Benchmarking setup -
I used the Shield TV, installed the benchmark build, and ran the startupBaselineProfileDisabled() test. Make sure to uninstall and reinstall the app before running the startupBaselineProfile() test.
Additionally, both tests have one warmup iteration to discard our first startup time where we copy a bunch of files.
Note -
Tests only can be run using the new "benchmark" build variant of the app. This is made to closely follow the release variant but not require keys for easy local testing.
This inadvertently adds Kotlin support to the app and we now have access to Macrobenchmarks!