I’m looking at compiling my Java app using a GraalVM native image but all the documentation I have seen refers to reduced startup times but make no reference to improvements in overall application performance?
So what can I realistically look forward to by doing this?
For existing Java applications, GraalVM can provide benefits by running them faster, providing extensibility via scripting languages, or creating ahead-of-time compiled native images.
GraalVM Native Image is an ahead-of-time compilation technology that generates native platform executables. Native executables are ideal for containers and cloud deployments as they are small, start very fast, and require significantly less CPU and memory.
Better overall throughput GraalVM Enterprise comes with a more powerful compiler—and it can create a profile of execution, similar to what a JIT compiler does during the runtime of the application. The compiler can use this profile for producing what's called profile-guided optimization (PGO) during AOT compilation.
GraalVM is production-ready software, available as Community Edition for an open-source license and as Oracle GraalVM Enterprise Edition accessible by accepting the OTN License Agreement Oracle GraalVM Enterprise Edition Including License for Early Adopter Versions.
In general, the performance decreases. I have reported the performance decrease of native images some time ago to the GraalVM team. The severity of performance decrease may vary on the use case(s). On the benchmarks I have written and used for my analysis (an updated version of the code can be found here), the overhead ranged from "barely noticeable" to "up to 5x slower". I also mentioned this shortly in my talk at JCON 2019 (#shamelessSelfPromotion).
There is a nice slide from the GraalVM team, illustrating what technology to use for which use case: (The image was taken from a tweet by Thomas Würthinger)
For the interested reader: As Andrew mentioned on github, a major factor of the bad performance is the non-existence of JIT-compilation: the JIT-compiler can, among other things, eliminate seldom-used branches and thus significantly speed up performance. This is obviously not possible with natively compiled code.
Side note: While we are on the topic of performance, you can execute bitcode emitted by clang (i.e. execute C
/C++
programs on GraalVM), but don't expect "good" performance at all... 😜
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With