The emulator is dead, long live the emulator!

TL;DR: Genymotion is not significantly faster than the official emulator (on Linux w/ KVM) but that’s not the only thing that matters!

You may have heard that there is an Android emulator and an iOS simulator. Ever wondered what the difference is?

Essentially, the Android emulator abstracts away the underlying hardware and emulates all of its functionality, as if it’s on an actual device. From the point of view of the OS, it’s running on yet another device type.

A simulator, by contrast, exposes more of the host machine and does not emulate things like the CPU, memory access, GPU access and other low-level functionality. This obviously reduces the overhead and in general leads to much better performance. The downside is that the simulator is even less similar to actual devices. It can become more of an intermediate “preview” stage than an actual “testing” stage.

The Android SDK comes with an emulator based on the open-source qemu project. It’s a proven, feature-rich piece of software, which can emulate all sorts of CPU architectures, even if they’re different from the host. Which is what got the Android emulator its bad rep.

Cross-architecture emulation is __

The only answer is slow.

Originally, the Android SDK releases only had ARM images for the emulator. What this means in real terms is that every instruction that the emulator tries to execute has to be translated into one or more instructions for the host processor (x86 most likely). This is an enormous overhead and it showed. The emulator became infamous for being really, really, really slow.

During this time, a few projects such as Android x86 and AndroVM emerged. They used versions of Android compiled for x86 which allowed them to be executed on an x86 host with very little overhead. The overhead was even less if your CPU had the virtualization extensions from your vendor - VT-x for Intel and AMD-V for AMD (these extensions make memory access much less cumbersome). These projects rightfully earned praise and love from developers around the world.

If it weren’t for them, Google might have never stepped up their game and released official x86 images for the emulator or added GPU acceleration.

Where we are now

These days, you can find official images for x86 and MIPS a few weeks after the ARM ones are released. And that’s great. The official emulator is fast now!

The emulator is dead, long live the emulator!

Recently, the people behind AndroVM released their newest iteration, Genymotion. It’s essentially Android running in a VirtualBox VM, with lots of easy-to-use toggles for sensors and hardware features.

And people started raving about how fast it is! How it beats the official emulator hands down! How it’s salvation incarnate!

The thing is, I tried it and didn’t notice any of these miraculous perfomance improvements. Could all these people actually be wrong? Could I be missing the benefits and chalking them off to placebo?

I can’t answer the former question but I can definitely answer the latter.

Informal benchmarks

I benchmarked CPU and GPU perfomance using Linpack for Android and GLBenchmark 2.7 (GFXBench). Both VMs were the standard Galaxy Nexus presets.

Genymotion and the Android emulator (qemu from now on) ran one at a time, on a freshly rebooted Fedora 18 machine and were shut down between the CPU and GPU benchmarks.

The machine is rather old - Core2 Duo CPU P9600 clocked at 2.66GHz, 8GB of RAM and a crappy NVIDIA 9200 GPU, kernel 3.9.11-200.fc18.x86_64.

Graphs below:

Linpack benchmark GLBenchmark

Conclusion

I think my brief benchmarking proved my hunch (which, actually, is a bit worrying - I’m afraid I might have influenced the results somehow).

The GPU performance is pretty much equivalent (that 0.95x result was actually a difference of 1fps). The bottleneck was clearly my laptop’s low-end GPU.

The CPU perfomance was more interesting and in my casual exploration I noticed a similar stuttering effect. The perfomance in Genymotion is not at all consistent and seeing how both VMs have access to /dev/kvm, I don’t actually understand why VirtualBox performs so erratically.

Further, I’m sure on other platforms the perfomance may not be so close and people might see a significant boost with Genymotion. (The whole Intel HAXM business is supposed to close the gap but I’ve never looked into how it actually works)

So is Genymotion any good?

It is, though for me it’s not perfomance reasons that make it good.

We desperately need better UX for the emulator and Genymotion demonstrates one way to do that. I absolutely hate that I need to have DDMS open to do anything more elaborate with the emulator. If they’re the push that Google needs to get a few designers on the emulator team, that’d be awesome!

However, most of the time I run emulators, they’re triggered by Jenkins and are off-screen, so I can’t easily use Genymotion for that. But that’s another story for another time.

I hope you found this summary and comparison interesting!

P.S. I didn’t actually benchmark it but host to guest I/O (e.g. adb install) was an order of magnitude faster with Genymotion, though qemu beat it on startup time. Genymotion also idled a few percent lower than qemu


← Packing luggage for developers (Teaser) Lightly poking Dalvik with a stick_→