ProtonAOSP features a number of performance improvements that make the overall system performance significantly better:
- Up to 18% faster app/menu/screen opening
- 16% faster screenshot capturing
- Up to 4x faster low-level memory management
- Faster image loading and saving (JPEG and PNG)
Benchmark results are available to quantify these performance improvements. Most of them are the result of empirically profiling for bottlenecks and optimizing accordingly.
The sections below describe the technical details of our optimizations. All pre-optimization profiling percentages were sourced from a Pixel 5 running ProtonAOSP 11.3.1, unless otherwise stated. “The Settings test” refers to opening and closing activities in Settings, specifically Developer Options because of the amount of preferences it contains.
Most of ProtonAOSP’s performance improvements are in native components, which comprise much of the system’s performance-critical code.
Android 11 switched to the Scudo memory allocator for security hardening, but this comes at the expense of performance. We trade the ability to detect memory usage bugs for performance instead by using the latest stable version of jemalloc, updated from the official repository.
We use an optimized fork of the ubiquitous zlib data compression library, zlib-ng, to improve compression and decompression performance for many use cases:
- HTTP gzip compression
- PNG compression (e.g. screenshot saving and image editing)
- Android resource loading
- ZIP archives
Combined with other improvements, this speeds up screenshot saving by 16% on the Pixel 5 and likely contributes to the faster cold app launches as well.
Apart from optimized algorithms, zlib-ng makes more use of NEON SIMD and other ARMv8.2 extensions such as CRC32 for performance.
We’ve disabled debug tracing in ART to save 33% of the 0.1% CPU time spent checking whether specific trace tags are enabled.
Improvements to ART’s garbage collection have been backported from Android 13 (AOSP master):
Low memory killer
The low memory killer, responsible for stopping background apps when memory is running low, has improvements backported from Android 13 (AOSP master) to kill apps faster:
- lmkd: move to foreground cpuset before killing
- lmkd: use fd cache for cgroup migration
- lmkd: migrate process to FOREGROUND sched group before kill
While we have more optimizations focused on native code, higher-level Java code has also been optimized according to simpleperf profiles.
Percentages in the following sections refer to global CPU time in the Settings test. In indented sections, the percentage is a fraction of the parent items.
Framework & core services
- Reduce reflection overhead (12% of 0.39% ART JNI trampolines)
- Replace ArrayMap with HashMap for performance (0.12%)
- Reduce debugging overhead
- Trace: Disable debug tracing in production builds (2% of 0.12% trace tags)
- Reduce interface method trampoline overhead (0.32%)
- Reduce unnecessary CPU-rendered screenshot captures (over 2%)
Raw benchmark results and analysis spreadsheets can be found in the Google Drive folder. Most of the results are from a Pixel 5 running Android 11.