Facebook Open Sources the ReDex Android Byte Code Optimizer

Sometime last year, Facebook enhanced the performance of its Android application dramatically with a byte code optimizing tool called ReDex.

Since ReDex has been open sourced. Android Developers can use this tool to optimize their own apps. The best part is that they can also use it as the basis for other Android optimizers.

In a very recent post on Facebook’s engineering blog, the company is explaining that classes in a .DEX file — the executable format that is used in Android — aren’t organized by how they are accessed when the mobile application starts, but simply by the order the build encountered them.

ReDex uses trace data gathered from the mobile application to try to determine which classes to be placed first in the .DEX file:

[minimizing] the number of fetches from flash [storage] needed to load byte code on startup.” Facebook claims optimizing its own app with ReDex reduced the on-disk footprint by 25 percent and sped up start time by 30 percent.

The enhanced and improved speeds, Facebook claimed, are most notable on older phones with slower flash memory in them, but on newer phones also showed a performance boost. Facebook’s test phone was a clean Nexus 4 running Android 4.4. This operating system is still used by about 35 percent of Android handsets. The results were that the launch time for its application was shaved down from 2 seconds to 1.6 seconds.

The runtime analysis is used to strip out metadata and interfaces that usually isn’t accessed at all, but the developer can supply small hints to ReDex about how to conduct the optimization for their mobile application. For instance, they can instruct some methods to be left alone completely even if they’re not directly accessed.

These optimizations will  happen after the application has built process. This means, in God loving theory, that they can complement other optimizations for Java that take place at the virtual machine level or on the language level, like the upcoming language modularity features planned for Java 9.

Optimizing Java byte code isn’t a new concept whatsoever. At least one of the other open source projects, ProGuard, optimizes Java applications by pruning the unused code in the mobile application. Yet ProGuard apparently does not organize classes by order of execution like ReDex does.


Categories: Linux, Programming

Tags: , , , , , ,

%d bloggers like this: