SlideShare a Scribd company logo
1 of 30
Download to read offline
Going AOT: Everything you need
to know about GraalVM for Java
applications
Alina Yurenko
Devoxx Greece
•Alina Yurenko / @alina_yurenko
•Developer Advocate for GraalVM at
Oracle
•Love open source and
communities 🤝
•Love both programming 👩💻 &
natural languages 🗣
•🐱🐶
About me
2
3
GraalVM 🚀
An advanced JDK with ahead-of-time
Native Image compilation
4
native-image MyMainClass
./mymainclass
JIT AOT
java MyMainClass
2017 Year
2018 2019 2020 2021 2022 2023
2005 2011
... ...
Sun Labs’
Maxine Java
JVM initial
release
December
Native Image
open sourced
April
Twitter uses
Graal JIT for
core
microservices
October
Micronaut
1.0 with
Native
Image
support
April
GraalVM 1.0
released
April
Thomas
Wuerthinger
joins Oracle and
starts Graal
compiler project
March
Spring Native
goes beta
November
Quarkus
1.0 with
Native
Image
support
May
GraalVM
goes GA
(19.0
release)
September
MicroDoc
announces
GraalVM for
embedded
July
Alibaba
deploys
Native
Image in
production
July
Facebook
deploys
GraalVM in
production
May
AWS SDK
support for
Native
Image
November
Spring Boot 3
with Native
Image support
December
OpenJDK
Galahad
project
proposed
July
Google Cloud
Platform SDK
support for
Native Image
June
GraalVM Free
Terms and
Conditions
license
September
GraalOS &
Layered
Native
Image
announced
March
Azure SDK
support for
Native
Image
September
Oracle Cloud
runs services
on GraalVM
Graal History
Copyright © 2024, Oracle and/or its affiliates
GraalVM Native Image AOT Compilation
7
Ahead-of-Time
Compilation
Application
Libraries
JDK
Substrate VM
Points-to Analysis
Run Initializations
Heap Snapshotting
Input:
All classes from application,
libraries, and VM
Code in
Text Section
Image Heap in
Data Section
Image Heap
Writing
Output:
Native executable
Compact
Packaging
8
GraalVM Native Image—Fast Start Up and Much More
Improved
Security
Fast Start
& Scale
Lower Resource
Usage
Predictable
Performance
Supported
Azure
AWS
GCP
OCI
9
Demo 🚀
10
Ready for GraalVM Native Image
graalvm.org/native-image/libraries-and-frameworks
Libraries, dynamic Java features, and Native Image
11
• Libraries might be Native-Image friendly out of the box
• twitter.com/YunaMorgenstern/status/1729039787351536084
• Libraries might include config for Native Image:
• github.com/h2database/h2database/blob/master/h2/src/main/META-INF/native-image/
• Libraries might contain config in the Reachability Metadata Repository
• github.com/oracle/graalvm-reachability-metadata/tree/master/metadata/io.netty
• You can use framework support to produce custom “hints” for Native Image
runtimeHints.resources().registerPattern(“config/app.properties”); //register resource
@Reflective //flag elements that require reflection
• You can use the Tracing Agent to produce the necessary config automatically
• graalvm.org/latest/reference-manual/native-image/metadata/AutomaticMetadataCollection/
• You can provide/extend config for reflection, JNI, resources, serialization, and predefined classes manually
in JSON:
• graalvm.org/latest/reference-manual/native-image/metadata/#specifying-metadata-with-json
Happy path;
most of the cases
Custom code
GraalVM Native Image & JUnit
12
@EnabledInNativeImage
• used to signal that the annotated test class or test method is
only enabled when executing within GraalVM native images
• when applied at the class level, all test methods within that class will be
enabled within a native image
@DisabledInNativeImage
• used to signal that the annotated test class or test method is
only disabled when executing within a GraalVM native image.
13
Let’s talk performance 🚀
Spring PetClinic on Oracle GraalVM - Peak Throughput
14
Spring PetClinic on Oracle GraalVM - Memory Efficiency
15
Spring PetClinic Performance on Oracle GraalVM
16
GraalVM CE with C2 JIT Oracle GraalVM Native Image
Memory Usage (max RSS) 1,029 MB 641 MB
Peak throughput 11,066 req/s 11,902 req/s
Throughput per memory 12,488 req/(GB*s) 18,569 req/(GB*s)
Tail latency (P99) 7.2ms 5.15ms
Startup 7,090ms 210ms
-38% lower
+8% higher
+49% better
-28% lower
34x faster
17
Tips, tricks, and best practices 👩🔬
Copyright © 2024, Oracle and/or its affiliates
Container Size (MB)
0
125
250
375
500
Debian 12-slim
+ JDK 21
Distroless Java 21 Distroless Java Base
+ jlink
Distroless Java Base
+ Native Image
Distroless Base
+ Native Image
Distroless Static
+ Native Image
18.1
36.3
48.9
127
199
405
95.5% container image size reduction
JDK’s Simple Web Server
18
GraalVM Native Image
JVM
Compact
Packaging
Cross-Platform Builds on GitHub Actions
19
Windows
Executable
macOS
Executable
Linux
Executable
.class
.jar
.class
.jar
GraalVM GitHub
Action 🏗
20
• Reduced attack surface area
due to dead code removal—
unused classes, methods, and
fields not included in
executable
Improved
Security • Not vulnerable to JIT
compiler attacks
all code is AOT compiled
• SBOM supporting industry
standards
Embedded in executables
CycloneDX format
• Not vulnerable to
deserialization attacks via
class loading—executable
includes only required and
specified classes
Reduced Attack Surface 🛡
• Migrate 🚀
• Add Native Build Tools
• Alternatively, use recent versions of frameworks
• Evaluate libraries: graalvm.org/native-image/libraries-and-frameworks
• Build and deploy 👷
• Build and test on GraalVM as the JVM, build with Native Image closer to the deployment
• Quick build mode with `-Ob`
• Use CI/CD systems (e.g. GitHub actions) for deployment and cross-platform builds
• Run faster 🚀
• PGO
• ML-enabled PGO
• G1 GC
• `-march=native`
Recommendations
22
What’s next for GraalVM
• Java 22 features
• The fastest GraalVM yet :)
• Developer experience improvements
Learn more: medium.com/graalvm
GraalVM for JDK 22 🚀
23
24
Demo 🚀
Layered Native Images
25
Micronaut base
Micronaut extensions
(Web, Data, Test)
Spring base
App 1
App 2 App 3
Deployment: resources sharing ☁
JDK base
Application code
Development: fast recompilation 🚀
JDK base + Micronaut base+ all extensions
App 4
GraalOS—Advanced cloud native application deployment platform
26
Fast Start
GraalOS applications
start fast with
virtually no cold start
cost
Low Latency
Excellent 99th
percentile latency
makes GraalOS
applications highly
responsive
Run On Demand
GraalOS applications
are automatically
suspended and
resumed on demand
—with no idle cost
Applications, not
Containers
GraalOS uses the latest
advances in x86 and
AArch64 processor
architectures for hardware
enforced application
isolation without containers
Reduced Memory
GraalOS applications
require significantly
less memory
resulting in reduced
operating costs
Cloud Native
With support for
stateful and stateless
services and
functions, GraalOS is
ideal for cloud native
applications
Runs applications as small, fast GraalVM Native Image compiled machine executables
Compact
Packaging
27
GraalVM Native Image—Ideal for Cloud Native Applications
Improved
Security
Fast Start
& Scale
Lower Resource
Usage
Predictable
Performance
Supported
Azure
AWS
GCP
OCI
Questions & let’s connect! GraalVM resources
Ευχαριστώ!
@alina_yurenko
29
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf

More Related Content

Similar to GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf

Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVMRyan Cuprak
 
GraalVM Overview Compact version
GraalVM Overview Compact versionGraalVM Overview Compact version
GraalVM Overview Compact versionscalaconfjp
 
Commit to excellence - Java in containers
Commit to excellence - Java in containersCommit to excellence - Java in containers
Commit to excellence - Java in containersRed Hat Developers
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGuillaume Laforge
 
GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28Jorge Hidalgo
 
Polyglot Applications with GraalVM
Polyglot Applications with GraalVMPolyglot Applications with GraalVM
Polyglot Applications with GraalVMjexp
 
Cloudfoundry Overview
Cloudfoundry OverviewCloudfoundry Overview
Cloudfoundry Overviewrajdeep
 
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx PluginGr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx PluginYasuharu Nakano
 
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX AppsFrom GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX AppsBruno Borges
 
Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)Jared Burrows
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introductionjyoti_lakhani
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules uploadRyan Cuprak
 
[JOI] TOTVS Developers Joinville - Java #1
[JOI] TOTVS Developers Joinville - Java #1[JOI] TOTVS Developers Joinville - Java #1
[JOI] TOTVS Developers Joinville - Java #1Rubens Dos Santos Filho
 
DCSF19 Docker Containers & Java: What I Wish I Had Been Told
DCSF19 Docker Containers & Java: What I Wish I Had Been ToldDCSF19 Docker Containers & Java: What I Wish I Had Been Told
DCSF19 Docker Containers & Java: What I Wish I Had Been ToldDocker, Inc.
 
Presentasi Adobe Camp 2012
Presentasi Adobe Camp 2012Presentasi Adobe Camp 2012
Presentasi Adobe Camp 2012Arie Prasetyo
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Ryan Cuprak
 

Similar to GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf (20)

Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
 
GraalVM Overview Compact version
GraalVM Overview Compact versionGraalVM Overview Compact version
GraalVM Overview Compact version
 
Commit to excellence - Java in containers
Commit to excellence - Java in containersCommit to excellence - Java in containers
Commit to excellence - Java in containers
 
Google App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and GaelykGoogle App Engine Java, Groovy and Gaelyk
Google App Engine Java, Groovy and Gaelyk
 
GraphQL-ify your APIs
GraphQL-ify your APIsGraphQL-ify your APIs
GraphQL-ify your APIs
 
GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28GraalVM - JBCNConf 2019-05-28
GraalVM - JBCNConf 2019-05-28
 
Polyglot Applications with GraalVM
Polyglot Applications with GraalVMPolyglot Applications with GraalVM
Polyglot Applications with GraalVM
 
Gradle - Build System
Gradle - Build SystemGradle - Build System
Gradle - Build System
 
Cloudfoundry Overview
Cloudfoundry OverviewCloudfoundry Overview
Cloudfoundry Overview
 
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx PluginGr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
Gr8conf EU 2013 Speed up your development: GroovyServ and Grails Improx Plugin
 
Gradle
GradleGradle
Gradle
 
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX AppsFrom GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
From GitHub Source to GitHub Release: Free CICD Pipelines For JavaFX Apps
 
Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)Make Your Build Great Again (DroidConSF 2017)
Make Your Build Great Again (DroidConSF 2017)
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
[JOI] TOTVS Developers Joinville - Java #1
[JOI] TOTVS Developers Joinville - Java #1[JOI] TOTVS Developers Joinville - Java #1
[JOI] TOTVS Developers Joinville - Java #1
 
DCSF19 Docker Containers & Java: What I Wish I Had Been Told
DCSF19 Docker Containers & Java: What I Wish I Had Been ToldDCSF19 Docker Containers & Java: What I Wish I Had Been Told
DCSF19 Docker Containers & Java: What I Wish I Had Been Told
 
Presentasi Adobe Camp 2012
Presentasi Adobe Camp 2012Presentasi Adobe Camp 2012
Presentasi Adobe Camp 2012
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]
 

Recently uploaded

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 

Recently uploaded (20)

Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 

GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf

  • 1. Going AOT: Everything you need to know about GraalVM for Java applications Alina Yurenko Devoxx Greece
  • 2. •Alina Yurenko / @alina_yurenko •Developer Advocate for GraalVM at Oracle •Love open source and communities 🤝 •Love both programming 👩💻 & natural languages 🗣 •🐱🐶 About me 2
  • 4. An advanced JDK with ahead-of-time Native Image compilation 4
  • 6. 2017 Year 2018 2019 2020 2021 2022 2023 2005 2011 ... ... Sun Labs’ Maxine Java JVM initial release December Native Image open sourced April Twitter uses Graal JIT for core microservices October Micronaut 1.0 with Native Image support April GraalVM 1.0 released April Thomas Wuerthinger joins Oracle and starts Graal compiler project March Spring Native goes beta November Quarkus 1.0 with Native Image support May GraalVM goes GA (19.0 release) September MicroDoc announces GraalVM for embedded July Alibaba deploys Native Image in production July Facebook deploys GraalVM in production May AWS SDK support for Native Image November Spring Boot 3 with Native Image support December OpenJDK Galahad project proposed July Google Cloud Platform SDK support for Native Image June GraalVM Free Terms and Conditions license September GraalOS & Layered Native Image announced March Azure SDK support for Native Image September Oracle Cloud runs services on GraalVM Graal History
  • 7. Copyright © 2024, Oracle and/or its affiliates GraalVM Native Image AOT Compilation 7 Ahead-of-Time Compilation Application Libraries JDK Substrate VM Points-to Analysis Run Initializations Heap Snapshotting Input: All classes from application, libraries, and VM Code in Text Section Image Heap in Data Section Image Heap Writing Output: Native executable
  • 8. Compact Packaging 8 GraalVM Native Image—Fast Start Up and Much More Improved Security Fast Start & Scale Lower Resource Usage Predictable Performance Supported Azure AWS GCP OCI
  • 10. 10 Ready for GraalVM Native Image graalvm.org/native-image/libraries-and-frameworks
  • 11. Libraries, dynamic Java features, and Native Image 11 • Libraries might be Native-Image friendly out of the box • twitter.com/YunaMorgenstern/status/1729039787351536084 • Libraries might include config for Native Image: • github.com/h2database/h2database/blob/master/h2/src/main/META-INF/native-image/ • Libraries might contain config in the Reachability Metadata Repository • github.com/oracle/graalvm-reachability-metadata/tree/master/metadata/io.netty • You can use framework support to produce custom “hints” for Native Image runtimeHints.resources().registerPattern(“config/app.properties”); //register resource @Reflective //flag elements that require reflection • You can use the Tracing Agent to produce the necessary config automatically • graalvm.org/latest/reference-manual/native-image/metadata/AutomaticMetadataCollection/ • You can provide/extend config for reflection, JNI, resources, serialization, and predefined classes manually in JSON: • graalvm.org/latest/reference-manual/native-image/metadata/#specifying-metadata-with-json Happy path; most of the cases Custom code
  • 12. GraalVM Native Image & JUnit 12 @EnabledInNativeImage • used to signal that the annotated test class or test method is only enabled when executing within GraalVM native images • when applied at the class level, all test methods within that class will be enabled within a native image @DisabledInNativeImage • used to signal that the annotated test class or test method is only disabled when executing within a GraalVM native image.
  • 14. Spring PetClinic on Oracle GraalVM - Peak Throughput 14
  • 15. Spring PetClinic on Oracle GraalVM - Memory Efficiency 15
  • 16. Spring PetClinic Performance on Oracle GraalVM 16 GraalVM CE with C2 JIT Oracle GraalVM Native Image Memory Usage (max RSS) 1,029 MB 641 MB Peak throughput 11,066 req/s 11,902 req/s Throughput per memory 12,488 req/(GB*s) 18,569 req/(GB*s) Tail latency (P99) 7.2ms 5.15ms Startup 7,090ms 210ms -38% lower +8% higher +49% better -28% lower 34x faster
  • 17. 17 Tips, tricks, and best practices 👩🔬
  • 18. Copyright © 2024, Oracle and/or its affiliates Container Size (MB) 0 125 250 375 500 Debian 12-slim + JDK 21 Distroless Java 21 Distroless Java Base + jlink Distroless Java Base + Native Image Distroless Base + Native Image Distroless Static + Native Image 18.1 36.3 48.9 127 199 405 95.5% container image size reduction JDK’s Simple Web Server 18 GraalVM Native Image JVM Compact Packaging
  • 19. Cross-Platform Builds on GitHub Actions 19 Windows Executable macOS Executable Linux Executable .class .jar .class .jar GraalVM GitHub Action 🏗
  • 20. 20 • Reduced attack surface area due to dead code removal— unused classes, methods, and fields not included in executable Improved Security • Not vulnerable to JIT compiler attacks all code is AOT compiled • SBOM supporting industry standards Embedded in executables CycloneDX format • Not vulnerable to deserialization attacks via class loading—executable includes only required and specified classes Reduced Attack Surface 🛡
  • 21. • Migrate 🚀 • Add Native Build Tools • Alternatively, use recent versions of frameworks • Evaluate libraries: graalvm.org/native-image/libraries-and-frameworks • Build and deploy 👷 • Build and test on GraalVM as the JVM, build with Native Image closer to the deployment • Quick build mode with `-Ob` • Use CI/CD systems (e.g. GitHub actions) for deployment and cross-platform builds • Run faster 🚀 • PGO • ML-enabled PGO • G1 GC • `-march=native` Recommendations
  • 23. • Java 22 features • The fastest GraalVM yet :) • Developer experience improvements Learn more: medium.com/graalvm GraalVM for JDK 22 🚀 23
  • 25. Layered Native Images 25 Micronaut base Micronaut extensions (Web, Data, Test) Spring base App 1 App 2 App 3 Deployment: resources sharing ☁ JDK base Application code Development: fast recompilation 🚀 JDK base + Micronaut base+ all extensions App 4
  • 26. GraalOS—Advanced cloud native application deployment platform 26 Fast Start GraalOS applications start fast with virtually no cold start cost Low Latency Excellent 99th percentile latency makes GraalOS applications highly responsive Run On Demand GraalOS applications are automatically suspended and resumed on demand —with no idle cost Applications, not Containers GraalOS uses the latest advances in x86 and AArch64 processor architectures for hardware enforced application isolation without containers Reduced Memory GraalOS applications require significantly less memory resulting in reduced operating costs Cloud Native With support for stateful and stateless services and functions, GraalOS is ideal for cloud native applications Runs applications as small, fast GraalVM Native Image compiled machine executables
  • 27. Compact Packaging 27 GraalVM Native Image—Ideal for Cloud Native Applications Improved Security Fast Start & Scale Lower Resource Usage Predictable Performance Supported Azure AWS GCP OCI
  • 28. Questions & let’s connect! GraalVM resources