3 ms·
Well, yeah, when you start developing for Android you quickly find out that Dalvik JIT is kinda crap and it just doesn't do inlining and hotspot optimizations v
by izacus 13y ago
Well, yeah, when you start developing for Android you quickly find out that Dalvik JIT is kinda crap and it just doesn't do inlining and hotspot optimizations very well.
Which means that pretty much computationaly intensive tasks (e.g. image processing, crypto, etc.) are several orders of magnitude slower than what you're used from desktop JVM. That's especially noticable in Android's BouncyCastle crypto implementation, where standard algorithms like PBKDF#2 derivation function can take ages (e.g. 3 seconds for 10.000 iterations on Nexus 4). Simply just moving those algorithms to C library without any optimizations quickly gives you orders of 100-500x speedups just from the GCC compiler (the before mentioned OpenSSL implementation of the derivation algorithm runs about 80-150ms for same parameters and result). So now we do pretty much any crypto or bitmap algorithms in C and just call C library via JNI.
Of course... most apps don't really do anything computationally expensive so C doesn't give much benefits.
- Iftheshoefits 13y agoIt's not just the tasks you list which are traditionally considered (relatively) computationally intensive, in my experience. I cringe at every loop wondering what the performance cost will be (it's not always clear or predictable). I'm almost at the point where I'd rather just write everything in C++, except for what absolutely cannot be.
- mdwrigh2 13y ago> I cringe at every loop wondering what the performance cost will be (it's not always clear or predictable). Really? I think it's fairly easy to determine what would be expensive vs. what's going to be relatively cheap. I'd love a counterintuitive example to prove me wrong though.