5,595,964 Members 31,935 Now Online
XDA Developers Android and Mobile Development Forum

[4.4/4.4.x][PATCH] Qualcomm-optimized Dalvik & Bionic libraries

Tip us?
 
kszaq
Old
(Last edited by kszaq; 8th March 2014 at 10:06 PM.) Reason: Edited Q&A, added newer version of Dalvik patch
#1  
Senior Member - OP
Thanks Meter 791
Posts: 289
Join Date: Apr 2011
Cool [4.4/4.4.x][PATCH] Qualcomm-optimized Dalvik & Bionic 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 @xboxfanj:
Quote:
Originally Posted by xboxfanj View Post
Part of the point of Nexus devices is that AOSP can produce nearly identical images minus GApps. Google would not use a proprietary dalvik as that is one of the core libraries. Using a proprietary dalvik would undermine AOSP. Although, an open libqc-dalvik or even just giving us that binary would be nice. Google could have a device specific extension similar to the adreno extensions onto renderscript and egl for dalvik. Proprietary dalvik won't happen, but an adreno extension could be cool.
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 @xboxfanj:
Quote:
Originally Posted by xboxfanj View Post
CAF has all Qualcomm's bionic patches and slight dalvik tweaks, however, the dalvik patches that are used here in the Moto X and any QCOM (non-Nexus) device, are mostly closed source. If you look at the change here: https://www.codeaurora.org/cgit/quic...739455dfd3cf57

You will see that most of that change is supporting other libraries (libqc-opt and libqc-dalvik), which is where their optimizations are. Unfortunately, both of those are closed source. libqc-opt is included in QCOM ROM zips as a shared library, so we can use that, however, libqc-dalvik is a static library, so we can't pull that from anywhere, as it is included in the libraries themselves and not put in system. This means that our only option to get all of Qualcomm's dalvik optimizations is to use their binaries rather than building from source, since building from source would mean missing any optimizations brought by libqc-dalvik, libqc-sqlite, and libqc-skia (the last two haven't been included in any patch, but are QCOM static libraries).

TLDR: QCOM's dalvik optimizations are closed source, so we are forced to use their binaries.
Remember to thank @xboxfanj 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/andro.../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!

KOT49E revert ZIP == KOT49H revert ZIP
Attached Files
File Type: zip 4.4_qc-optimized_dalvik.zip - [Click for QR Code] (572.4 KB, 29986 views)
File Type: zip 4.4_qc-optimized_bionic.zip - [Click for QR Code] (366.4 KB, 22334 views)
File Type: zip KRT16S_stock_revert.zip - [Click for QR Code] (764.6 KB, 2427 views)
File Type: zip KOT49E_stock_revert.zip - [Click for QR Code] (768.5 KB, 5470 views)
File Type: zip 4.4_qc-optimized_dalvik-cm11.zip - [Click for QR Code] (532.4 KB, 1611 views)
The Following 338 Users Say Thank You to kszaq For This Useful Post: [ Click to Expand ]
 
sub1287
Old
#2  
sub1287's Avatar
Senior Member
Thanks Meter 1184
Posts: 1,375
Join Date: Feb 2013
Nice job on the new thread!

Pure Speed X💉 ~ ViPER4Android 🎧 [n⁴]
Warning!....this post was carelessly typed and mostly sarcastic!
 
meangreenie
Old
#3  
meangreenie's Avatar
Senior Member
Thanks Meter 559
Posts: 1,974
Join Date: Mar 2012
Yep, good to have a dedicated thread.

I did notice a slight change, with there being no more dexopt file, just checking that this is correct?
The Following User Says Thank You to meangreenie For This Useful Post: [ Click to Expand ]
 
LudicrousPeed
Old
#4  
LudicrousPeed's Avatar
Senior Member
Thanks Meter 24
Posts: 106
Join Date: Jul 2012
In the benchmarks thread, I saw a comment that it probably won't work on CyanogenMod ROMs. Is that true?

Sent from my SCH-I535 using Tapatalk
 
max4wdc
Old
(Last edited by max4wdc; 27th November 2013 at 10:44 PM.)
#5  
Senior Member
Thanks Meter 136
Posts: 253
Join Date: Dec 2011
i got bootloop !
with 4.4 stock.
-----------------------------------------------
Quote:
I tested the patches on my custom ROM and it seemed to me that I didn't need to replace dexopt binary anymore yet from your bootloops it looks like we have to replace it anyhow. Thank for noticing! I've uploaded an updated dalvik patch, please try it now.
now it's working , my apps is upgrading now
it's boring (289 apps .... :| )
 
moxtrom
Old
#6  
Member
Thanks Meter 31
Posts: 46
Join Date: Feb 2011
Location: Santiago
Another bootloop in Stock 4.4.
And if like me, you didn't make a whole system backup, I've attached the original files.
Attached Files
File Type: zip 4.4_original_bionic.zip - [Click for QR Code] (366.5 KB, 943 views)
File Type: zip 4.4_original_dalvik.zip - [Click for QR Code] (518.4 KB, 983 views)
The Following 10 Users Say Thank You to moxtrom For This Useful Post: [ Click to Expand ]
 
ofan666
Old
#7  
Junior Member
Thanks Meter 2
Posts: 12
Join Date: Sep 2013
i have no bootloop flashed both files, after install, i did wipe cache and dalvik cache. But previously i already did patch motoX_4.4_qcoptimized.zip from kszaq posted at Nexus 4 Benchmark thread. I have Stock ROM + Kernel.
 
max4wdc
Old
#8  
Senior Member
Thanks Meter 136
Posts: 253
Join Date: Dec 2011
i see you change the dalvik file( "4.4_qc-optimized_dalvik.zip") !
i'm testing your new file .
 
kszaq
Old
#9  
Senior Member - OP
Thanks Meter 791
Posts: 289
Join Date: Apr 2011
Quote:
Originally Posted by meangreenie View Post
Yep, good to have a dedicated thread.

I did notice a slight change, with there being no more dexopt file, just checking that this is correct?
Quote:
Originally Posted by max4wdc View Post
i got bootloop !
with 4.4 stock.
I tested the patches on my custom ROM and it seemed to me that I didn't need to replace dexopt binary anymore yet from your bootloops it looks like we have to replace it anyhow. Thank for noticing! I've uploaded an updated dalvik patch, please try it now.

Quote:
Originally Posted by LudicrousPeed View Post
In the benchmarks thread, I saw a comment that it probably won't work on CyanogenMod ROMs. Is that true?

Sent from my SCH-I535 using Tapatalk
It works for me on CyanogenMod. I figured out that the reason for it not having worked before was that CyanogenMod uses a modified installd binary (they patched it for Dexroot on Cache). As this is the only change they made I included stock installd binary (from stock Nexus 4 ROM) to make dalvik patch work with CM and any ROM that uses their base.
The Following User Says Thank You to kszaq For This Useful Post: [ Click to Expand ]
 
max4wdc
Old
#10  
Senior Member
Thanks Meter 136
Posts: 253
Join Date: Dec 2011
Quote:
Originally Posted by kszaq View Post
I tested the patches on my custom ROM and it seemed to me that I didn't need to replace dexopt binary anymore yet from your bootloops it looks like we have to replace it anyhow. Thank for noticing! I've uploaded an updated dalvik patch, please try it now.



It works for me on CyanogenMod. I figured out that the reason for it not having worked before was that CyanogenMod uses a modified installd binary (they patched it for Dexroot on Cache). As this is the only change they made I included stock installd binary (from stock Nexus 4 ROM) to make dalvik patch work with CM and any ROM that uses their base.
now work on 4.4 stock .

Tags
bionic, dalvik, qc-opt
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes