Baseline Profiles

Akarsh Mittal
Bobble Engineering
Published in
3 min readNov 4, 2022
This diagram displays the baseline profile workflow from upload through end-user delivery, and how that workflow relates to cloud profiles.

Do you know that starting with Android 9, almost all apps on Play Store were optimized automatically, without a single line of code added by any of the developers? Cold Startup across a plethora of apps showed an average of 15%, with some apps like google search showing an improvement of 30% on certain devices. How did this happen and where do baseline profiles fit in? Let's find out!

Profiles

Android runtime (ART) includes just in time (JIT) compiler as well as ahead of time (AOT) compiler. If an app is completely JIT/AOT compiled, it will result in a significant reduction in performance. During the transition period of Dalvik to ART, apps were compiled ahead of time on android 5 and 6. This significantly increased the app install time, RAM and disk usage. A balance between JIT and AOT compilation is the most optimized approach. That’s where profiles factor in. Starting with Android 7, Android Runtime improves the app’s performance by building a profile of the app’s most important/frequently used code (HOT code). This is called Profile Guided Optimization (PGO). The only disadvantage is the time taken to achieve this optimization.

ART optimizing profiles in the cloud

Generally, apps have commonly used code paths (hot code) among a multitude of users and devices. Keeping the same in mind, starting from android 9, android runtime uploads the profile data to the play cloud. All such profiles from different users are aggregated and result in the building of the core code profile. Now, these profiles are shipped along with the apk to the end users as dex metadata files. Thus if these cloud profiles are available when a new user freshly installs an app or an existing user updates the app from the play store, he/she can experience the improvement of the app’s performance right from the get-go!

This diagram displays the cloud profiles workflow

Further Improvements

What if the developer frequently updates his/her app? This may result in the user installing the app without the cloud profiles being available. Baseline profiles help in these situations, where a baseline/minimum performance improvement is guaranteed to the user. The baseline profile is built by the developer and includes the code that he/she deems fit to be optimized. The developer can also test those profiles on his/her system, thus the performance gains would be similar to those seen by the users.

--

--