All Libraries Are Equal, or Are They?

We have been working with some of our customers on improving the performance of Android on Intel devices, both 32 and 64-bit. As part of that effort we benchmarked a variety of different parts of the Android system and wanted to share some interesting results.

The lowest common denominators in any Android App are the system services. These provide the basic building blocks that allow the App to do interesting things. Similarly, NDK code depends upon the fundamental libraries that provide it with the built-in features of the C or C++ languages used to write most native code.

Android contains “Bionic”, a custom implementation of these system libraries. Bionic was developed to provide a very compact version of the libraries with implementations suited to running on less powerful mobile devices. We were interested in the performance of Bionic, because any improvements made here would automatically benefit a wide range of Apps.

One of the parts of Bionic we investigated was the maths library, libm. We were able to access the version customized by Intel that is made available to their phone and tablet manufacturers who are using Intel SoCs. We compared the Intel libm with the standard version and found it significantly faster in benchmarks which make use of math functions, as detailed below:

Benchmark

Test

Intel libm

Performance Advantage

Antutu

Multitask

63%

CPU Float

55%

Geekbench

Black-Scholes

18.1%

Dijkstra

1.49%

We performed these tests on 32-bit systems and showed that even on more mature Android platforms there is scope for processor specific optimizations. The low level analysis we did using our Prism toolset indicated some very interesting optimizations and it is clear that significant effort has gone into optimizing it. There are of course other cases of platform specific software releases, e.g. several custom versions of the Android Java Runtime have been developed for specific SoCs.

Further opportunities for processor specific optimizations will open up when you move to 64-bit. More registers and newer hardware should help those trying to boost performance. In fact we recently gave a talk at AnDevCon (PDF Slides here) to discuss some of the ways App developers can take best advantage of those 32 extra bits, and avoid the pitfalls.

One of the advantages that Intel devices have during the move to 64-bit is the years of optimization work that have gone on in the PC desktop market since the start of its transition to 64-bit in 2003.

As we have seen, processor specific optimized libraries can make a significant impact in boosting App performance. In the particular case of Intel, it is to be expected that their many years of 64-bit deployment have yielded some highly optimized libraries and it is good to know that app developers get access to these optimizations without having to lift a finger. After all, there’s no point in re-inventing the wheel.