4 ms·
If you're prepared to do all that, why not write the hot code in C and use JNI?
by anonymous 13y ago
If you're prepared to do all that, why not write the hot code in C and use JNI?
- noelwelsh 13y agoIf you go C/JNI you: 1. Have added an extra step to your build process 2. Pay the cost of doing JNI calls, which I believe is quite high. Look, I'm not saying doing this Unsafe stuff is rainbows and unicorns. It's a hack, but it's a hack that is extremely useful in a few niche applications.
- kasey_junk 13y agoJNI calls carry a very significant latency overhead. If the code you are trying to optimize would have to call the JNI methods repeatedly you very quickly lose any speed advantage you had from writing it in C. If on the other hand you only need to call the JNI a few times it probably does make sense to go the JNI route. Another common option (especially in server style programs) is to have 2 daemons, one in C (or C++) doing a very specialized role and communicating with a JVM daemon via memory mapped files.