Wednesday, May 15, 2013

Binary translation vs native x86 code

I recently bought an Asus Fonepad partly because I wanted to test an Intel based Android device. It turned out it's a really nice device and surprisingly almost everything I tried on it worked well. I didn't expect this since many apps contains native code and a lot of them only comes with native code compiled for ARM based devices.

After some research I found out that Intel based Android devices comes with a library (libhoudini.so) that uses binary translation to translate native ARM code into native x86 code. This explains the very good app compatibility but it also made me wonder how much performance we give up for compatibility.

As I noticed that the Epic Citadel app performed almost identical on my Nexus 4 and the Fonepad I had a look into the apk and noticed it comes with native code for both ARM and x86 devices. That gave me an idea and I created two versions of the apk. On version only contains the native ARM code and the other only the native x86 code. That allowed me to do a comparison and here's the results.

The tests was made on an Asus Fonepad with firmware version 3.1.17 and version 1.0.5 of the Epic Citadel app.

First out is the version with only native ARM code:


Then another run with the version with only native x86 code:


As you can see the version with native x86 code scored over 40% better compared to the version that relied on binary translation.

So while the binary translation is a good thing for compatibility there is also a risk that developers takes the easy route and decides not to include native x86 code for their apps.

3 comments:

  1. Can you please post the x86 apk? I'd like to give a pure x86 native game a try on my Fonepad.

    ReplyDelete
    Replies
    1. Sorry, no, removing the ARM lib means you have resign the apk with a different key than the original one and I don't want to be responsible for distributing a "hacked" version of their app.

      However it is easy to do yourself if you have the APK. Just open it up with your favorite ZIP-application (I use 7-zip) and delete the /lib/x86 folder. Then resign the apk and install it on your device. To sign it, just google for testsign.jar and you should be able to find both the .jar file and some instructions.

      Delete
  2. how you generate the x86 code libraries

    ReplyDelete