Speed up your Nexus with optimized libraries, here’s how

Advertisement

When talking about our smartphones and tablets, there seem to be two things we always want more of: battery life, and speed. Ironically, the two may not be mutually exclusive, since completing tasks faster means the processor can return to a more energy-efficient speed quicker. How the speed boost is achieved will have a significant impact on how much battery life will be saved — or squandered. Overclocking and overvolting are two popular ways to speed up any device, but they’re also notorious for causing more power drain and increased heat — both will zap your battery fast! There’s another way to speed up your device: improve the efficiency and speed at which your apps run. Doing so may be easier than you might think thanks to a hack involving a couple optimized Nexus libraries.

This isn’t your mother’s library

LibraryThe libraries that we’re talking about don’t hold books, instead, they’re collections of code that apps use to do all the things that they do. These libraries can be built such that they do the same thing as any other version of the same library, but do so in a more optimized or efficient manner. Sounds crazy, right?

Lets hop out of code and into the real world for a moment.

I love rice, but it takes so long to cook. Sometimes when I want to eat my rice, I want it in just a few minutes. Luckily, there’s a solution for that! Minute Rice! Is this some special variety of rice that’s harvested only in the tropical jungles of some far-off land? No! Is it a genetically modified organism that is specifically designed for its quick-cookability? No! It’s essentially pre-cooked rice that has been dried out, and is ready for you to add water and heat.

Optimized libraries are somewhat similar. Instead of being “pre-cooked”, libraries can be optimized so they are simply faster than other versions, or they can be targeted to specific processors, so the code runs faster on one set of hardware than it does on another. That’s exactly how the Moto X gets away with the performance that it does, while running on fairly conservative hardware

Why doesn’t everyone do it?

To answer that question we need to look at a recent hack that can help speed up your Nexus.

Bionic

The first half of this hack is the “bionic patch”. libbionic is based on the standard GNU C library which you can find in BSD as glibc. The full-blown glibc library is designed to run on desktop computers, workstations, and servers — it was never intended to run on smartphones and tablets. As such, glibc is relatively “heavy”, and depends on high-end processors with bunches of RAM to run quickly.

Google stripped the library down, optimized it for mobile, and called it libbionic. Both libraries are used for various math and memory operations.

The “bionic patch” uses from the open source Code Aurora Foundation rather than Google’s own code. Why it hasn’t been adopted by Google for use in the AOSP is anyone’s guess.

Dalvik

dalvik

The second half of this hack gets to the heart of Android itself: the virtual machine. Most Android-powered devices run their apps in the Dalvik VM. Dalvik is a runtime environment which not only allows apps to run on different platforms without having to be recompiled for each one, but also provides a layer of protection between apps and the operating system itself.

Google knows that Dalvik is a bottleneck and is working on a new runtime called ART: Android Runtime. ART is available on some Nexus devices running Android 4.4 KitKat, but is very much experimental. It’s intended to improve performance and extend battery life, and it generally does both, though it may be difficult to see the results in everyday use.

Google is working toward making the new runtime the default runtime environment, but it’s not ready just yet. In the meantime, OEMs can optimize Dalvik for their particular hardware, and that’s just what Motorola and Qualcomm have done with the version of Dalvik included in the Moto X.

Doesn’t Google own Motorola? Yes, you are correct! Why hasn’t Google adopted the Dalvik optimizations included in the Moto X in the Nexus family, or even in the AOSP code itself? The Dalvik optimizations from the Moto X aren’t open-source; AOSP is.

Suffice it to say, if your device is running a similar chip as the one inside the Moto X, it can probably benefit from running the Moto X’s Dalvik runtime.

Enough with the geek speak! Does it actually work?

Pocketnow reader Andrew Roach has been following the developments of this hack and tried it out on his devices. According to his experimentation, “any hint of lag is gone and (the One S) performs very close to the Moto X both in UI smoothness and benchmarks”. He got similar results when he applied the hack to his 2013 Nexus 7, where he saw “a tangible increase in real life, and benchmark performance as well”.

dalvik-vs-art-2

Results on the Nexus 5, however, are a mixed bag. Performance is noticeably better than running “stock” and benchmarks are higher on single-core processes, but about the same on multi-core processes. When running the stock libbionic with the experimental ART, single-core processes are about the same, but multi-core processes are quite a bit faster.

How do I do it?!

Are you ready to try this hack out on your device? That’s what I thought!

The first thing you’ll need to do, of course, is assume the risk. You’ll be neck-deep in warranty voiding action here!

twrpNext, you’ll want a rooted device running your favorite Custom Recovery (TWRP worked just fine for me). Since this hack covers so many devices I won’t be able to go into detail on how to oem unlock and root your device, but with today’s Rooting Toolkits, voiding your warranty has never been easier!

After that, make a backup. I cannot stress this enough. Yes, you could revert the two new libraries with the old ones, but that means you’d have to back them up first, then restore them and apply the proper permissions… Work, work, work. Just back up your whole device instead.

Last, you’ll need to download the two libraries and flash them to your device from your Custom Recovery. After that, simply reboot and you’re done!

One word of caution: if you’re going to try this out, you’re probably breaking your ability to get official, OTA updates to your device, but since you’re using a Custom Recovery, you probably already knew that.

How did it work for you?

Are you one of the brave and daring like Andrew? If so we’d love to know what kind of performance you’re getting after applying this hack. Let us know what device you’re on, what kind of battery improvements you see (if any), and where you noticed speed improvements.

Head down to the comments and share your experiences, and give Andrew a virtual pat on the back while you’re at it!

Image Credits: Wikipedia, techie-Z-junkyard

Advertisement

What's your reaction?
Love It
0%
Like It
0%
Want It
0%
Had It
0%
Hated It
0%
About The Author
Joe Levi
Joe graduated from Weber State University with two degrees in Information Systems and Technologies. He has carried mobile devices with him for more than a decade, including Apple's Newton, Microsoft's Handheld and Palm Sized PCs, and is Pocketnow's "Android Guy".By day you'll find Joe coding web pages, tweaking for SEO, and leveraging social media to spread the word. By night you'll probably find him writing technology and "prepping" articles, as well as shooting video.Read more about Joe Levi here.