13

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?

Clancy Merrick
  • 855
  • 1
  • 8
  • 16

1 Answers1

16

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...

Turing85
  • 18,217
  • 7
  • 33
  • 58
  • 4
    In general the peak throughput of a native image is not as great as when you run in the JIT mode though the long-term goal is to improve AOT compilation to be comparable to warmed up JIT. As the image linked explains there are different things people assume when say performance, for example -- lower memory consumption might allow you to scale better and achieve better overall throughput. – Oleg Šelajev Dec 30 '19 at 10:17