How We Slashed Android Startup Time by 30% with Baseline Profiles
Article Summary
Duolingo's Android team cut startup time by 30% with baseline profiles. But the path from 'easy setup' to production was anything but smooth.
The team implemented Android baseline profiles to pre-compile critical code at install time, reducing the JIT compilation burden. What looked like a straightforward integration turned into a months-long debugging saga involving invalid profiles, incompatible third-party libraries, and build process mysteries.
Key Takeaways
- Startup time improved 30%, JIT thread usage dropped from 25% to 3%
- Two different third-party libraries were silently invalidating baseline profiles
- Side-loaded testing showed gains, but production builds failed completely
- Macrobenchmark library bugs forced creative workarounds during validation
- Added custom build step to regenerate profiles after dex modifications
Baseline profiles delivered massive performance wins, but debugging required Google's direct support and custom build process modifications to work around third-party library issues.
About This Article
Duolingo's baseline profiles kept getting invalidated when the Android App Bundle packaging process ran. A third-party library was swapping two dex files, which caused the profile conversion to fail silently in production builds.
The team built a custom step into their build process that regenerates baseline profiles using the modified dex files. This worked around the library's bug while they waited for the maintainers to fix it.
Music lesson jank decreased noticeably. The team also figured out how to adopt Jetpack Compose without worrying about performance, which opens the door for UI modernization down the road.