[Nexus 4 General] kszaq:
For most up-to-date information on optimized libraries, please carefully read [MENTION=4544860]osm0sis[/MENTION]'s post: http://xdaforums.com/showpost.php?p=53963337&postcount=1287

You should also read [MENTION=5666997]Lethargy[/MENTION]'s post in the Nexus 5 thread: http://xdaforums.com/showpost.php?p=56038135&postcount=2918.

The outdated flashable ZIPs from this post have been deleted. Head over to post linked above for the latest libraries.

Have you ever wondered why your Nexus 4 performs worse than other flagship devices with the same quad-core CPU in benchmarks? Not any more! I present you with a very simple patch that will boost your performance to what other APQ8064-based devices offer.

Before using, please read the following Q&A.

Q: Will this void my warranty?

A: Yes. Flash at your own risk.

Q: Can I use it?

A: Yes, if you're on any 4.4/4.4.x ROM.

Q: How does this work?

A: This patch consists of two files that include optimized bionic and Dalvik libraries for any KitKat ROM.

Q: What is bionic?

A: It is a vital system library that provides i.a. basic math and memory access functions to every other library and application in Android.

Q: What is Dalvik?

A: In short, Dalvik is a virtual machine in which every not-native-code app runs. You can read more about it in a Wikipedia article.

Q: How do I benefit from this patch?

A: In two ways: bionic patch provides faster memory access and optimized some of the math operations, dalvik provides optimized Dalvik Virtual Machine library that allows faster code execution.

Q: Do I need this patch?

A: It depends on what ROM you are using:

if you're on stock ROM, you'll benefit from flashing both bionic and dalvik patches,

if you're using a custom ROM, you most probably don't need bionic patch, as these are already included in most custom ROMs. You'd benefit only from flashing dalvik patch (if it's not already included by your ROM maintainer, of course),

don't use the bionic patch on CyanogenMod, PSX and probably others, because they already have more optimized versions!

Q: Why aren't these patches included in stock ROM?

A: As for bionic - I don't know. Maybe that's because Google didn't want to include vendor-specific optimizations in AOSP or maybe simply because Qualcomm never posted them in Android Code Review to be merged. As for dalvik - because they are closed-source. Here'a a good explanation by [MENTION=4003363]xboxfanj[/MENTION]:

Q: Where do these patches come from?

A: These have been authored by Qualcomm. Bionic patch comes from Code Aurora Forum, Dalvik library has been extracted from Moto X 4.4. ROM. Another good read by [MENTION=4003363]xboxfanj[/MENTION]:

Remember to thank [MENTION=4003363]xboxfanj[/MENTION] for his very useful posts!

Q: What is the reason for including installd file?

A: The installd binary is from stock Nexus 4 ROM and is included for compatibility with CyanogenMod and CM-based ROMs. This is because CyanogenMod changed installd to work with their dexopt-on-cache (see here: https://github.com/CyanogenMod/android_frameworks_native/commits/cm-11.0/cmds/installd) and it you don't flash stock installd you'd get hundreds of FCs and unusable ROM.

Q: How do I use this patch?

A: Simple flash it over your current ROM in recovery. Remember to wipe Dalvik Cache after flashing. Full wipe is

not

needed.

Q: How do I revert?

A: Simply flash over your current ROM and wipe Dalvik Cache afterwards. Full wipe is

not

needed.

Q: Can I flash it over an ODEXed ROM?

A: Yes, but it is strongly recommended to use a deodexed ROM if you want to use Dalvik patch.

Q: How will this affect my battery life?

A: It will be at least the same, if not better. Better performance = less CPU time spent on calculations = better battery life.

Q: I don't see any performance gains in some app, why is that?

A: The dalvik patch doesn't affect apps that use native libraries, i.e. you won't see much performance gain in Chrome etc.

Q: I'm on X kernel, can I use it?

A: Yes, use it with any kernel you like.

Q: Can I use it on other devices?

A: Yes, you can use this patch on every Krait device that uses AOSP-based ROM (examples: Nexus 5, Nexus 7 2013). Don't flash it on stock ROM on non-Nexus devices, as they already include these optimizations (that includes Galaxy S4 and HTC One Google Play editions!).

Q: What if I use it on stock ROM and OTA arrives? Can I install the OTA straight away?

A: You can't. You have to revert to stock libraries first. Keep in mind that

every

modification to stock ROM can mean problems when installing an OTA. You should revert to fully stock ROM to properly apply an OTA. For your courtesy, there's a revert ZIP attached for KRT15S and KOT49E ROMs. Remember that the safest way it to flash system.img from a factory image before applying an OTA once you made modifications to your /system partition!

Q: Can I use these patches on 4.4.1/4.4.2 stock ROM (KOT49E/KOT49H)?

A: Yes, you can.

Q: Can I use ART with this patch installed?

A: Yes, but you won't see any performance gains. In fact, with this patch Dalvik is faster than ART. I suppose ART will supersede Dalvik in performance in the future, but not yet.

Q: Where can I see some benchmark results before I flash?

A: Head over to Nexus 4 Benchmarks thread.

Q: Do I need to be rooted to flash this?

A: No. The only thing you need is custom recovery (CWM, TWRP etc.).

Q: Do I have to flash these patches every time I install an update/new ROM?

A: Yes.

Don't replace these files on a running system (i.e. via a file explorer or adb)! If you do this, your phone will stop working and you'd have to reflash your ROM to make it work again. And you'll probably loose some data by doing so. Always use recovery to replace these libraries.

If you're running CM11 released after 1 March 2014 or any other ROM that includes fixes to DVM, please flash 4.4_qc-optimized_dalvik-cm11.zip. This is the only file you need, don't flash anything else from this thread!