GraalVM - A Step Ahead of JVM Presentation

knoldus 48 views 25 slides Jul 12, 2024
Slide 1
Slide 1 of 25
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25

About This Presentation

Explore the capabilities of GraalVM in our upcoming session, where we will cover key aspects such as optimizing startup times, enhancing resource efficiency, and enabling seamless language interoperability. Learn how GraalVM can significantly improve your application's performance and versatilit...


Slide Content

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.

Introduction to GraalVM Features of  GraalVM JIT vs AOT Spring with AOT Cons of GraalVM Demo Performance comparison of JVM and AOT

Introduction to  GraalVM 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

Features of  GraalVM 02

Features of  GraalVM Low Resource Usage Improved Security Fast Startup  & Scale Compact Packaging Multiple framework support Cloud support Polyglot Programming

JIT vs AOT 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

Spring with AOT 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

Cons of  GraalVM 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.

DEMO 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: Linux macOS Windows 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

Performance Comparison of JVM and AOT 07

Performance Comparison

Thank you
Tags