jokerconf Joker 2018 (19.10.2018)

Compiling Java ahead-of-time with GraalVM

img

We’ll talk about configuration of SubstrateVM, special aspects of its approach to code compiling and its limitations. We’ll discuss which programs might and should be compiled ahead-of-time, look at applications already working and at their performance.

GraalVM is a high-performance virtual machine for different programming languages. It supports many popular languages: Java, Kotlin, Scala, JavaScript, Python, Ruby, R, even the likes of С и C++. GraalVM has an interesting feature: it can compile JVM bytecode into machine code ahead-of-time, creating images of the common Java programs, which do not depend on JVM, can be launched in milliseconds and require less memory. This can be done on the special virtual machine — SubstrateVM, which is written on Java and offers its own implementations for garbage collecting, code cash, flow control, and other JVM components.

We’ll talk about configuration of SubstrateVM, special aspects of its approach to code compiling and its limitations. We’ll take a look at the internal analysis of Java programs and at what exactly happens when the image is being created (at this moment you might experience mixed feelings for static initializers in the code and for rarely updated libraries). We’ll figure out how and why we should configure the use of Reflection API, access to resource files, JNI, Unsafe, and all the other little things of the common Java applications. We’ll show how to use profile-guided optimizations for creating quick images which do not lose information about potential profile of using the code. We’ll discuss which programs might and should be compiled ahead-of-time, look at applications already working and their performance.