GraalVM – A step
ahead of JVM
Presented by:
Vimal & Sakshi
Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
 Punctuality
Join the session 5 minutes prior to the session start time. We start on
time and conclude on time!
 Feedback
Make sure to submit a constructive feedback for all sessions as it is very
helpful for the presenter.
 Silent Mode
Keep your mobile devices in silent mode, feel free to move out of session
in case you need to attend an urgent call.
 Avoid Disturbance
Avoid unwanted chit chat during the session.
1. Introduction to GraalVM
2. Features of GraalVM
3. JIT vs AOT
4. Spring with AOT
5. Cons of GraalVM
6. Demo
7. Performance comparison of JVM and AOT
01
GraalVM
 High-performance JDK designed to enhance Java application performance
 Consumes fewer resources compared to standard JDKs
 Graal Compiler:
Functions as a Just-In-Time (JIT) compiler for running Java applications on the HotSpot JVM
Supports Ahead-Of-Time (AOT) compilation into native executables
 Polyglot Capabilities
Provides runtimes for multiple languages, including JavaScript, Ruby, Python, and more
Security and Optimization
 Reduced Attack Surface:
Excludes unused classes, methods, and fields from the application binary
 Extended JVM Capabilities:
Offers new performance optimizations and capabilities beyond standard JVM implementations
JIT and AOT Code Compilation
GraalVM
GraalVM
Java
JIT
java MyMainClass
AOT
Native-image MyMainClass
./mymainclass
GraalVM Native Image AOT Compilation
Application
Libraries
JDK
Substrate VM
Point-to analysis
Run initialization
Heap snapshot
Application
classes & libraries
GraalVM
Native executable
02
Features of GraalVM
Low Resource Usage Improved Security
Fast Startup &
Scale
Compact
Packaging
Multiple framework support
Cloud support
Polyglot Programming
03
JIT v/s AOT
Factors JIT(Just-In Time) AOT(Ahead Of Time)
Timing of Compilation
Compiles code just before execution
during runtime.
Compiles code before runtime, usually
during the
build or deployment phase.
Execution Efficiency
Optimizes code based on runtime
profiling and platform-
specific characteristics
Generates optimized native code
upfront, ensuring consistent
performance from the start
Startup Time
May lead to longer startup times
initially due to compilation overhead
Generally, results in faster startup times
as code is already compiled to
native machine code
Dynamic Code Adaptation
Can dynamically optimize code based
on runtime conditions and usage
patterns.
Optimizations are fixed during
compilation and cannot adapt
dynamically at runtime
Deployment and Distribution
Requires distributing bytecode or
intermediate code for compilation on
user machines
Involves distributing pre-compiled
native binaries, simplifying deployment
and ensuring consistency
across environments
04
Spring AOT
SPRING BOOT
RUN-TIME
DISCOVERY AND
CONFIGURATION
NATIVE IMAGE
BUILD-TIME
DISCOVERY AND
CONFIGURATION
Spring AOT
SPRING BOOT NATIVE IMAGE
SPRING AOT
Spring AOT
SPRING AOT
JAVA SOURCE
FILES
BYTECODE
HINT
FILES
Cross Platform Builds on GitHub Actions
.jar
.jar
.class
GraalVM GitHub Action
Linux Executable
MacOS Executable
Windows Executable
05
Cons of Graal VM
• Longer Build Times
Build times for native images are longer compared to standard JVM applications
• Maturity and Stability
GraalVM is relatively new compared to the standard JVM, which may result in stability
issues
• Platform dependent
Native compilation requires same machine config on which it is intended to be executed
• Controlled support for Dynamic Features
Dynamic class loading and reflection need explicit configuration to implement and
optimize in native images.
06
Demo POC
Goals & Objective
• Application Compilation: Successfully compile the Spring Boot app to a native
image
• Functional Validation: Ensure all functionalities work in the native image.
• Performance Benchmarks: Compare startup times, response times, and throughput.
• Memory Footprint Analysis: Document memory usage under various loads.
• Resource Utilization: Measure CPU and memory usage of the native image versus
the JVM version
Prerequisite
• If you have GraalVM already installed and have experience using it, you can skip else need
to set it up for your operating system
• Choose your operating system and proceed to the installation steps for your specific
platform:
o Linux
o macOS
o Windows
o Docker Container
• Once you set up the GraalVM you check it using java -version
• Install the native image extensions
• gu install native-image can verify using native - -version
Build container images with GraalVM and buildpacks
• Add below to your pom.xml
• Build the image
07
Performance Comparison
Thank you

GraalVM - A Step Ahead of JVM Presentation

  • 1.
    GraalVM – Astep ahead of JVM Presented by: Vimal & Sakshi
  • 2.
    Lack of etiquetteand manners is a huge turn off. KnolX Etiquettes  Punctuality Join the session 5 minutes prior to the session start time. We start on time and conclude on time!  Feedback Make sure to submit a constructive feedback for all sessions as it is very helpful for the presenter.  Silent Mode Keep your mobile devices in silent mode, feel free to move out of session in case you need to attend an urgent call.  Avoid Disturbance Avoid unwanted chit chat during the session.
  • 3.
    1. Introduction toGraalVM 2. Features of GraalVM 3. JIT vs AOT 4. Spring with AOT 5. Cons of GraalVM 6. Demo 7. Performance comparison of JVM and AOT
  • 4.
  • 5.
    GraalVM  High-performance JDKdesigned to enhance Java application performance  Consumes fewer resources compared to standard JDKs  Graal Compiler: Functions as a Just-In-Time (JIT) compiler for running Java applications on the HotSpot JVM Supports Ahead-Of-Time (AOT) compilation into native executables  Polyglot Capabilities Provides runtimes for multiple languages, including JavaScript, Ruby, Python, and more Security and Optimization  Reduced Attack Surface: Excludes unused classes, methods, and fields from the application binary  Extended JVM Capabilities: Offers new performance optimizations and capabilities beyond standard JVM implementations
  • 6.
    JIT and AOTCode Compilation GraalVM GraalVM Java JIT java MyMainClass AOT Native-image MyMainClass ./mymainclass
  • 7.
    GraalVM Native ImageAOT Compilation Application Libraries JDK Substrate VM Point-to analysis Run initialization Heap snapshot Application classes & libraries GraalVM Native executable
  • 8.
  • 9.
    Features of GraalVM LowResource Usage Improved Security Fast Startup & Scale Compact Packaging Multiple framework support Cloud support Polyglot Programming
  • 10.
  • 11.
    JIT v/s AOT FactorsJIT(Just-In Time) AOT(Ahead Of Time) Timing of Compilation Compiles code just before execution during runtime. Compiles code before runtime, usually during the build or deployment phase. Execution Efficiency Optimizes code based on runtime profiling and platform- specific characteristics Generates optimized native code upfront, ensuring consistent performance from the start Startup Time May lead to longer startup times initially due to compilation overhead Generally, results in faster startup times as code is already compiled to native machine code Dynamic Code Adaptation Can dynamically optimize code based on runtime conditions and usage patterns. Optimizations are fixed during compilation and cannot adapt dynamically at runtime Deployment and Distribution Requires distributing bytecode or intermediate code for compilation on user machines Involves distributing pre-compiled native binaries, simplifying deployment and ensuring consistency across environments
  • 12.
  • 13.
    Spring AOT SPRING BOOT RUN-TIME DISCOVERYAND CONFIGURATION NATIVE IMAGE BUILD-TIME DISCOVERY AND CONFIGURATION
  • 14.
    Spring AOT SPRING BOOTNATIVE IMAGE SPRING AOT
  • 15.
    Spring AOT SPRING AOT JAVASOURCE FILES BYTECODE HINT FILES
  • 16.
    Cross Platform Buildson GitHub Actions .jar .jar .class GraalVM GitHub Action Linux Executable MacOS Executable Windows Executable
  • 17.
  • 18.
    Cons of GraalVM • Longer Build Times Build times for native images are longer compared to standard JVM applications • Maturity and Stability GraalVM is relatively new compared to the standard JVM, which may result in stability issues • Platform dependent Native compilation requires same machine config on which it is intended to be executed • Controlled support for Dynamic Features Dynamic class loading and reflection need explicit configuration to implement and optimize in native images.
  • 19.
  • 20.
    Demo POC Goals &Objective • Application Compilation: Successfully compile the Spring Boot app to a native image • Functional Validation: Ensure all functionalities work in the native image. • Performance Benchmarks: Compare startup times, response times, and throughput. • Memory Footprint Analysis: Document memory usage under various loads. • Resource Utilization: Measure CPU and memory usage of the native image versus the JVM version
  • 21.
    Prerequisite • If youhave GraalVM already installed and have experience using it, you can skip else need to set it up for your operating system • Choose your operating system and proceed to the installation steps for your specific platform: o Linux o macOS o Windows o Docker Container • Once you set up the GraalVM you check it using java -version • Install the native image extensions • gu install native-image can verify using native - -version
  • 22.
    Build container imageswith GraalVM and buildpacks • Add below to your pom.xml • Build the image
  • 23.
  • 24.
  • 25.