The size of an OTA update isn’t something that most people really think about, since updates generally automatically download in the background over WiFi, but it’s actually a big deal on the server back end. Saving even a few megabytes of data can make a huge difference since the gains are multiplied by potentially hundreds of thousands of users. To that end, Google has been working to bring its Brotli compression algorithm to Android for faster OTA updates.
What is the Brotli Compression Algorithm?
Brotli is a compression algorithm developed by a few Google employees that significantly improves the compression ratio over other algorithms such as GZIP while also demonstrating an impressive decompression speed. The downside is that compressing files with the Brotli algorithm is rather slow, so it’s generally avoided when compressing dynamic content.
Compression Benchmarks. Source: Jeroen Ooms
On the other hand, any static content such asweb pagesare suitable to be compressed via the Brotli algorithm. This includes application files downloaded from the Google Play Store. Since there are well over 2 billion Android devices out there, shaving off even small amounts of data when serving a patch file from the Play Store can result in massive gains for Google. The Brotli algorithm, when used for Play Store app downloads , saves users 1.5 petabytes (1.5 million gigabytes) of data each day .
Brotli Compression Algorithm versus GZIP for Play Store Downloads. Credits: Google Student Blog
How will Brotli Improve OTA Updates?
Now, OTA updates aren’t served to users as frequently as a Play Store app update, but they do tend to be much larger in comparison. For example, a full OTA package before compression can be 2GBs in size. Just how much data can be saved from an OTA package?
ALineageOS developer for the MotorolaMoto G4 reports that they were able to save 50 Megabytes on an unofficial build. Considering the fact that the average Moto G4 LineageOS build is about 350 Megabytes , that’s a pretty dramatic improvement. If even 10 MBs of data is saved on each OTA, then the overall reduction in bandwidth can be significant since Google needs to serve the update package to hundreds of thousands of users.
Furthermore, since Brotli also brings improved decompression speeds, that also means that OTA updates can be applied more quickly. OTA updates are sent to each device as an archive, so before the patches can be made via bsdiff , the archive needs to be decompressed. Since Brotli decompression is rather quick that means decompressing the archive will also be quick, resulting in faster patching of system files.
However, users on devices with A/B partition schemes such as theGoogle Pixel/Pixel 2,Essential Phone, Razer Phone,Moto Z2 Force, andXiaomi Mi A1probably won’t notice this particular improvement since the updates are seamlessly applied on the inactive partition in the background. Still, even for these devices, the smaller OTA update package due to Brotli compression will result in reduced bandwidth for the user.
Thanks to XDA Retired Forum Moderator/Recognized Developercybojenix for the tip!