Recommended flags
The flags are in thebazelrc configuration syntax, so
they can be pasted directly into a bazelrc file and invoked with
--config=<configuration_name> on the command line.
Profiling performance
Bazel writes a JSON trace profile by default to a file called
command.profile.gz in Bazel’s output base.
See the JSON Profile documentation for
how to read and interact with the profile.
Persistent workers for Android build actions.
A subset of Android build actions has support for
persistent workers.
These actions’ mnemonics are:
- DexBuilder
- Javac
- Desugar
- AaptPackage
- AndroidResourceParser
- AndroidResourceValidator
- AndroidResourceCompiler
- RClassGenerator
- AndroidResourceLink
- AndroidAapt2
- AndroidAssetMerger
- AndroidResourceMerger
- AndroidCompiledResourceMerger
--config=android_workers on the command line:
4. We have
measured improved build performance
by capping the number of instances for each action to 1 or 2, although this
may vary depending on the system Bazel is running on, and the project being
built.
To cap the number of instances for an action, apply these flags:
aapt2 has improved
performance over aapt and also creates smaller APKs. To use aapt2, use the
--android_aapt=aapt2 flag or set aapt2 on the aapt_version on
android_binary and android_local_test.
SSD optimizations
The --experimental_multi_threaded_digest flag is useful for optimizing digest
computation on SSDs.