3 ms·
The GC isn't the feature you want though, it's the JIT compiler. JIT compilers optimise based on the actual runtime characteristics of the running code, not th
by kitd 8y ago
The GC isn't the feature you want though, it's the JIT compiler.
JIT compilers optimise based on the actual runtime characteristics of the running code, not the best guesses that a static compiler has to make. The effect can be significant. It's no surprise that the Java leaders in Techempower benchmarks match or surpass the C++ ones.
- zozbot123 8y agoYou can use profile-guided compilation with an AOT compiler, too-- Or you could just add optimization hints to the performance-critical parts of the code. Either way, the compiler doesn't need to "guess"
- gpderetta 8y agoAlso one of the advantages of JIT is that it can take advantage of whatever dedicated instruction is available on the current CPU, while an AOT compiler (discounting runtime dispatching) need to target the lowest common denominator. In this case though you would know exactly the target hardware.
- adrianN 8y agoOn the other hand, the JIT has to balance the runtime of its optimization passes with the expected improvement in execution speed of the code. An AOT compiler can afford much more expensive optimizations.
- kod 8y agoI've talked with HFT firms that spent effort fighting the JIT because they cared more about the latency of rarely reached code paths than the common path.
- twic 8y agoJava doesn't beat C++ in raw computational benchmarks. The JIT compiler is a marvel, but it doesn't beat peer AOT compilers. The Techempower benchmarks mostly show how good the entrant's web-serving stack is. Java has a couple of decades of multiple skilled, well-established groups competing to build the fastest web stack. C++ has Boost.Beast, which, although its developers are smart, wise, widely respected, sexy, and moderators of a Slack i frequent, can't compete in terms of resources.
- MaxBarraclough 8y agoI think you're overstating the importance of JIT vs AOT. There are a few AOT-compiling JVMs out there, and it's not the case that they reliably outperform the JIT-based JVMs like HotSpot. The significant differences are in Java mandating array bounds checks, runtime checking for null, no undefined behaviour, etc.