After many years of development, Oracle finally published GraalVM and sparkled a lot of interest in the community. GraalVM is a high-performance polyglot VM with a number of potentially interesting traits we can take advantage of like increased performance and lowered cost. It can also tackle shortcomings of JVM/Scala we are struggling for years like slow-startup times or large jars. Lastly, thanks to its polyglot nature it can open interesting doors we may want to discover. On the other hand, GraalVM may still be bleeding edge technology and having a hard time to deliver the promised features. In this talk, I’d like to discuss advantages and disadvantages of adopting GraalVM, provide you guidance if you decide to do so and also share our story in this area including various samples, and recommendations. This talk is focused on JVM and Scala but should be beneficial for everyone with interested in this topic.
15. Compilation & JVM
Just-in-time (JIT)
● Compiles while running
● Dynamic compilation
● Runtime information
● De-optimization
● Typical for JVM
Ahead-of-time (AOT)
● Compiles before running
● Static compilation
● More resources
● Way more time
● Uncommon for JVM (JDK 9+)
29. ● JVM starts slowly
● Scala makes it worse
● JARs bloat up quickly
● JVM needs a lot of RAM
JVM Shortcomings
30. JDK 1.8 (JIT)
time java -jar primes.jar
real 0m0.555s
user 0m0.613s
sys 0m0.075s
vs.
GraalVM (AOT)
<path-to-graal>/bin/native-i
mage -jar primes.jar
time ./primes
real 0m0.039s
user 0m0.004s
sys 0m0.010s
Counting Primes
31. JDK 1.8 (JIT)
time java -jar primes.jar
real 0m11.954s
user 0m14.077s
sys 0m0.739s
vs.
GraalVM (AOT)
<path-to-graal>/bin/native-i
mage -jar primes.jar
time ./primes
Segmentation fault: 11
real 0m0.324s
user 0m0.245s
sys 0m0.077s
Counting Primes