Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does GraalVM native image increase overall application performance or just reduce startup times?

Tags:

java

graalvm

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?

like image 979
Clancy Merrick Avatar asked Dec 26 '19 12:12

Clancy Merrick


People also ask

Is GraalVM faster?

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.

What is GraalVM native image?

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.

Is GraalVM better?

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.

Is GraalVM production ready?

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.


1 Answers

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: As tweeted by @thomaswue (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... 😜

like image 156
Turing85 Avatar answered Oct 05 '22 21:10

Turing85