Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GraalVM JIT & AOT @ Codemotion Madrid 2023

GraalVM JIT & AOT @ Codemotion Madrid 2023

Slides for my talk about "GraalVM JIT & AOT" at Codemotion Madrid 2023.

Jorge Hidalgo

May 10, 2023
Tweet

More Decks by Jorge Hidalgo

Other Decks in Programming

Transcript

  1. Three languages for the Elven fullstack developers under the sky,

    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!
  2. GRAALVM – This is not the Java you used to

    know – Jorge Hidalgo Codemotion Madrid 2023 – 10th May 2023
  3. Principal Director – Software Engineering Group – Accenture Spain Global

    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
  4. • Polyglot virtual machine by Oracle Labs • JVM languages,

    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
  5. • GraalVM as a drop-in replacement for JDK • Java

    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
  6. GraalVM This is the high-level internal architecture of GraalVM Java

    HotSpot VM SubstrateVM JVM Compiler Interface Graal Compiler Truffle Framework Sulong JVM components GraalVM components components to be moved into OpenJDK
  7. • Easy to start: GraalVM can be used simply as

    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?
  8. • JVM JIT (just in time) compiler optimization has a

    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
  9. GraalVM Java Native Images – High-level development cycle Develop locally

    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