Seven for the Dwarf backend developers in their halls of stone, (*) Nine for the Mortal frontend developers doomed to die, One for the Compiler Lord on his AST throne In the Land of Bytecodes where the programs lie. One VM to rule them all, One VM to find them, One VM to bring them all, And in Bytecodes bind them, In the Land of Bytecodes where the programs lie. (*) The languages are doomed to die, not the developers!
Java Community of Practice co-lead Spain Cloud First DevOps lead Spain Adv. Tech. Center Cloud First Architecture & DevOps & Cloud lead Communities matter: MálagaJUG / Málaga Scala Developers / BoquerónSec co-lead Co-organizer: OpenSouthCode Málaga (June 9th-10th 2023 come and enjoy with us!) Father of two, husband, whistle player, video gamer, sci-fi *.*, Lego, Raspberry Pi, Star Wars, Star Trek, LOTR, Halo, Borderlands, Watch Dogs, Diablo, StarCraft, Black Desert,… LLAP! ABOUT ME @deors314 in/deors JORGE HIDALGO
and much more! • Faster, leaner, production-ready (for many use cases) • Two flavours: • Open source (community edition) • Enterprise edition with further enhancements • Announced during JavaOne 2022: Key portions of GraalVM CE will be moved under OpenJDK project governance – JIT Compiler, AOT Compiler and Native Image GraalVM https://graalvm.org – current version is 22.3.2
native images (superb for containers/serverless) • Polyglot VM (Truffle) • Language interoperability • VM for native languages (LLVM) • Common debugging interface • Common monitoring interface • Java programs as native libraries (easier than JNI!) GraalVM Main use cases In bold, the two most relevant use cases for JVM developers
HotSpot VM SubstrateVM JVM Compiler Interface Graal Compiler Truffle Framework Sulong JVM components GraalVM components components to be moved into OpenJDK
an alternative to OpenJDK to run JVM programs • In many cases, programs executed with GraalVM have better performance and memory footprint out of the box • JIT and AOT – generate native images for cloud-native architectures: very low start-up times (superb for functions) and compact binaries (superb for increased density of cloud workloads) • Not everything is perfect – e.g. expect longer compilation times in AOT mode GraalVM Why use GraalVM?
steep ramp up curve – great for long-running processes • JIT is not very good for short lived processes – in those situations start-up time is a major concern (more relevant than peak performance) • GraalVM can be used as an AOT (ahead of time) compiler to create native images (thanks to Substrate VM) • Paves the way for the “faster, leaner Java” movement – Micronaut, Quarkus, Helidon or Spring Native GraalVM Java Native Images
using GraalVM as drop-in replacement to JDK Package as native image (may need a container runtime) Test native image Push code/config changes or push tested image GraalVM behaves just as a regular JDK New commands and switches to control Graal specifics If working on Windows/macOS a native binary will run on Windows/macOS only! Running the native binary build in a Linux container means that the native binary is Linux and as such compatible with container runtimes Behavior should mostly be the same, just faster However always test the native image before commiting the changes Remember that a native image is generally great for short-term programs or functions but JIT is still great in many use cases Depending on the workflow, either push code changes (and a CI/CD pipeline will produce the native image) or push the tested image directly to a container registry