Android app update file sizes get shrunken by 65%

There was a time, back in the old Symbian and Windows CE days, when app sizes, were only measured in kilobytes. These days, however, it isn't unusual for apps to go into megabyte territory, and we're not talking just about games either. Technology and the price of components have made it far too easy to take file sizes for granted, but just because we can doesn't mean we should. Especially when it comes to app updates, which, ideally, should be smaller than the original app download itself. Taking up the cause for smaller file sizes, Google has revealed a new technique to keep updates to a minimum, reducing sizes by 65% on average.

To be clear, this new technique doesn't actually change the file size of the initial app installation. Like the bsdiff algorithm introduced last July, the focus here is in reducing the file size of app updates. In an ideal setting, updates shouldn't be as large as the full app, since it should only change what was really changed, not download the whole thing again. In reality, things are a bit tricky.

The new technique is being called "File-by-File patching" and it does exactly that. Android apps are packaged into APKs, which are technically just ZIP files with special features. The problem with compressed packages like this is changing even a small part of just one file in the set can lead to a huge difference in the signature of the compressed package. To get around this to reduce the file size, Android developers had to employ a few tactics and what looks like a rather complicated process.

First, Google Play Service uncompresses both old and new versions of the app and then computes the difference between the actual files in them rather than just the difference between the APKs. It then sends the device this patch, which is basically just a smaller file describing what has changed in between versions. To apply the patch on the device's end, Android first checks if the original, older APK's signature matches the canonical one on Google Play Store (i.e., it hasn't been tampered with), uncompresses the APK, applies the patch only to the files that changed, and then compresses the files again into an APK, using the same compression settings that the developer used. This results in an updated APK that exactly matches the new version on uploaded by the app developer.

Google claims that, on average, app update sizes are reduced by 65%. Some can even go up to 90%. To put it into a bigger perspective, that is said to be a savings of 6 petabtyes (6,000,000 GB) of data per day. There is, however, a drawback with the File-by-File patching method, as the uncompressing, patching, and recompressing process does take up some processor work and longer time. Processor cycles and I/O read/write processes, however, are significantly cheaper, almost free, than cellular data charges, so it might be worth the wait. But to be sure, Google is only using the method to apps that are auto-updated, usually when the user is asleep.

SOURCE: Google