SlideShare une entreprise Scribd logo
1  sur  39
Télécharger pour lire hors ligne
Adopting GraalVM
@petr_zapletal
GraalVM: Run Programs Faster Anywhere
Compiling with GraalVM
sbt --java-home <path-to-graal-vm>
-XX:+UnlockExperimentalVMOptions
-XX:+EnableJVMCI
-XX:+UseJVMCICompiler
● JDK 10/11 requires Scala 2.13
Limitations & Challenges
● JDK 10/11 requires Scala 2.13
● Limited library support
Limitations & Challenges
● JDK 10/11 requires Scala 2.13
● Limited library support
● Scaladex
Limitations & Challenges
● JDK 10/11 requires Scala 2.13
● Limited library support
● Scaladex
● Disabling compiler optimization
Limitations & Challenges
JDK 11
[success] Total time: 571 s, ...
real 12m48.492s
user45m40.264s
sys 2m31.045s
vs.
Graal
(using the flags)
[success] Total time: 507 s, ...
real 11m34.191s
user41m52.512s
sys 2m12.863s
Stopwatch Compiling
GraalVM Runtime
Just-in-time compilation
Compilation & JVM
Just-in-time (JIT)
● Compiles while running
● Dynamic compilation
● Runtime information
● De-optimization
● Typical for JVM
Ahead-of-time (AOT)
● Compiles before running
● Static compilation
● More resources
● Way more time
● Uncommon for JVM (JDK 9+)
java -XX:+UnlockExperimentalVMOptions
-XX:+EnableJVMCI
-XX:+UseJVMCICompiler
object Main extends App {
val max = 10000000
def isPrime(n: Int): Boolean =
primes.takeWhile(p => p*p <= n).forall(n % _ != 0)
val primes = 2 #:: Stream.from(3,2).filter(isPrime)
primes.takeWhile(_ <= max).toList
}
Primes
Primes
object Main extends App {
val max = 10000000
def isPrime(n: Int): Boolean =
primes.takeWhile(p => p*p <= n).forall(n % _ != 0)
val primes = 2 #:: Stream.from(3,2).filter(isPrime)
primes.takeWhile(_ <= max).toList
}
Primes
object Main extends App {
val max = 10000000
def isPrime(n: Int): Boolean =
primes.takeWhile(p => p*p <= n).forall(n % _ != 0)
val primes = 2 #:: Stream.from(3,2).filter(isPrime)
primes.takeWhile(_ <= max).toList
}
Primes
object Main extends App {
val max = 10000000
def isPrime(n: Int): Boolean =
primes.takeWhile(p => p*p <= n).forall(n % _ != 0)
val primes = 2 #:: Stream.from(3,2).filter(isPrime)
primes.takeWhile(_ <= max).toList
}
jdk 1.8.0_161-b12
time <path-to-java>/java -jar
primes.jar
real 0m11.646s
user0m14.286s
sys 0m0.657s
vs.
graalvm-ee-1.0.0-rc8
time <path-to-graal>/java
-XX:+UnlockExperimentalVMO
ptions
-XX:+EnableJVMCI
-XX:+UseJVMCICompiler
-jar primes.jar
real 0m13.478s
user0m29.199s
sys 0m0.975s
Primes
class Primes {
@Benchmark
@BenchmarkMode(Array(Mode.AverageTime))
@OutputTimeUnit(TimeUnit.MICROSECONDS)
def getPrimes() = primes.takeWhile(_ <= max).toList
}
object Main extends App {
new Primes().getPrimes()
}
Primes II
class Primes {
@Benchmark
@BenchmarkMode(Array(Mode.AverageTime))
@OutputTimeUnit(TimeUnit.MICROSECONDS)
def getPrimes() = primes.takeWhile(_ <= max).toList
}
object Main extends App {
new Primes().getPrimes()
}
Primes II
jdk 1.8.0_161-b12
jmh:run -i 10 -wi 10 -f4 -t4
Primes
[info] Benchmark Mode Cnt
Score Error Units
**[info] Primes.getPrimes
avgt 40 45652.951 ±
2083.281 us/op**
vs.
graalvm-ee-1.0.0-rc8
jmh:run -i 10 -wi 10 -f4 -t4
Primes
[info] Benchmark Mode Cnt
Score Error Units
**[info] Primes.getPrimes
avgt 40 40535.844 ±
1977.021 us/op**
Primes II
(Early) Adopters
GraalVM Runtime
Ahead-of-time compilation
<path-to-graal>/bin/native-image
● JVM starts slowly
● Scala makes it worse
● JARs bloat up quickly
JVM Shortcomings
JDK 1.8 (JIT)
time java -jar primes.jar
real 0m0.555s
user 0m0.613s
sys 0m0.075s
vs.
GraalVM (AOT)
<path-to-graal>/bin/native-i
mage -jar primes.jar
time ./primes
real 0m0.039s
user 0m0.004s
sys 0m0.010s
Counting Primes
JDK 1.8 (JIT)
time java -jar primes.jar
real 0m11.954s
user 0m14.077s
sys 0m0.739s
vs.
GraalVM (AOT)
<path-to-graal>/bin/native-i
mage -jar primes.jar
time ./primes
Segmentation fault: 11
real 0m0.324s
user 0m0.245s
sys 0m0.077s
Counting Primes
● Small programs/scripts
● Alexa apps
● AWS Lambdas (using GO
runtime)
Use Cases
Do you want to use Scala
in cases like these?
There is More
Summary
Questions
References
References
● https://github.com/scala/make-release-notes/blob/2.13.x/projects-2.13.md
● https://index.scala-lang.org/search?q=fullScalaVersion%3A2.13.0-M5
● https://github.com/oracle/graal/blob/master/substratevm/LIMITATIONS.md
● https://www.youtube.com/watch?v=Rvb-kvuPzqI
● https://github.com/chrisseaton/graalvm-ten-things
● https://www.youtube.com/watch?v=wBegU4d4GRc
● https://engineering.opsgenie.com/run-native-java-using-graalvm-in-aws-lambda-with-golan
g-ba86e27930bf
● https://medium.com/graalvm/instant-netty-startup-using-graalvm-native-image-generation-
ed6f14ff7692
● https://www.infoq.com/articles/Graal-Java-JIT-Compiler
● https://medium.com/graalvm/compiling-scala-faster-with-graalvm-86c5c0857fa3
Images
● https://cdn.app.compendium.com/uploads/user/e7c690e8-6ff9-102a-ac6d-e4aebca50
425/d7eaeb73-4b9e-4764-ad10-b5785d99d114/Image/497cab5d0638a34c8a08194ef
b83b2fc/announcing_graalvm_version7.png
● https://cdn-images-1.medium.com/max/2000/1*rHZFwj8uu-x8KVCItuu53Q.png
● https://unsplash.com/photos/4m7gmLNr3M0
● https://www.tecflow.com/uk/images/slechte-koude-start-tecflow.jpg

Contenu connexe

Tendances

Tendances (20)

DIY Java Profiler
DIY Java ProfilerDIY Java Profiler
DIY Java Profiler
 
톰캣 #09-쓰레드
톰캣 #09-쓰레드톰캣 #09-쓰레드
톰캣 #09-쓰레드
 
Java profiling Do It Yourself (jug.msk.ru 2016)
Java profiling Do It Yourself (jug.msk.ru 2016)Java profiling Do It Yourself (jug.msk.ru 2016)
Java profiling Do It Yourself (jug.msk.ru 2016)
 
gRPC with Scala and Swift
gRPC with Scala and SwiftgRPC with Scala and Swift
gRPC with Scala and Swift
 
Embedded systems
Embedded systems Embedded systems
Embedded systems
 
Java memory problem cases solutions
Java memory problem cases solutionsJava memory problem cases solutions
Java memory problem cases solutions
 
Mastering java in containers - MadridJUG
Mastering java in containers - MadridJUGMastering java in containers - MadridJUG
Mastering java in containers - MadridJUG
 
(PFC302) Performance Benchmarking on AWS | AWS re:Invent 2014
(PFC302) Performance Benchmarking on AWS | AWS re:Invent 2014(PFC302) Performance Benchmarking on AWS | AWS re:Invent 2014
(PFC302) Performance Benchmarking on AWS | AWS re:Invent 2014
 
How to cook lettuce @Java casual
How to cook lettuce @Java casualHow to cook lettuce @Java casual
How to cook lettuce @Java casual
 
Kafka monitoring and metrics
Kafka monitoring and metricsKafka monitoring and metrics
Kafka monitoring and metrics
 
Путь мониторинга 2.0 всё стало другим / Всеволод Поляков (Grammarly)
Путь мониторинга 2.0 всё стало другим / Всеволод Поляков (Grammarly)Путь мониторинга 2.0 всё стало другим / Всеволод Поляков (Grammarly)
Путь мониторинга 2.0 всё стало другим / Всеволод Поляков (Grammarly)
 
GitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons LearnedGitLab PostgresMortem: Lessons Learned
GitLab PostgresMortem: Lessons Learned
 
淺談 Java GC 原理、調教和 新發展
淺談 Java GC 原理、調教和新發展淺談 Java GC 原理、調教和新發展
淺談 Java GC 原理、調教和 新發展
 
A little systemtap
A little systemtapA little systemtap
A little systemtap
 
Nine Circles of Inferno or Explaining the PostgreSQL Vacuum
Nine Circles of Inferno or Explaining the PostgreSQL VacuumNine Circles of Inferno or Explaining the PostgreSQL Vacuum
Nine Circles of Inferno or Explaining the PostgreSQL Vacuum
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumps
 
Troubleshooting PostgreSQL with pgCenter
Troubleshooting PostgreSQL with pgCenterTroubleshooting PostgreSQL with pgCenter
Troubleshooting PostgreSQL with pgCenter
 
Performance and stability testing \w Gatling
Performance and stability testing \w GatlingPerformance and stability testing \w Gatling
Performance and stability testing \w Gatling
 
Performance is a feature! - London .NET User Group
Performance is a feature! - London .NET User GroupPerformance is a feature! - London .NET User Group
Performance is a feature! - London .NET User Group
 
I know why your Java is slow
I know why your Java is slowI know why your Java is slow
I know why your Java is slow
 

Similaire à Adopting GraalVM - Scala eXchange London 2018

Slaven tomac unit testing in angular js
Slaven tomac   unit testing in angular jsSlaven tomac   unit testing in angular js
Slaven tomac unit testing in angular js
Slaven Tomac
 
OSCON2012TroubleShootJava
OSCON2012TroubleShootJavaOSCON2012TroubleShootJava
OSCON2012TroubleShootJava
William Au
 

Similaire à Adopting GraalVM - Scala eXchange London 2018 (20)

Adopting GraalVM - NE Scala 2019
Adopting GraalVM - NE Scala 2019Adopting GraalVM - NE Scala 2019
Adopting GraalVM - NE Scala 2019
 
Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018Adopting GraalVM - Scale by the Bay 2018
Adopting GraalVM - Scale by the Bay 2018
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
Jvm Performance Tunning
Jvm Performance TunningJvm Performance Tunning
Jvm Performance Tunning
 
JavaCro'14 - Unit testing in AngularJS – Slaven Tomac
JavaCro'14 - Unit testing in AngularJS – Slaven TomacJavaCro'14 - Unit testing in AngularJS – Slaven Tomac
JavaCro'14 - Unit testing in AngularJS – Slaven Tomac
 
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
State of Java Elasticity. Tuning Java Efficiency - GIDS.JAVA LIVE 2020
 
Java and Containers: What's there to think about? | DevNation Tech Talk
Java and Containers: What's there to think about? | DevNation Tech TalkJava and Containers: What's there to think about? | DevNation Tech Talk
Java and Containers: What's there to think about? | DevNation Tech Talk
 
Slaven tomac unit testing in angular js
Slaven tomac   unit testing in angular jsSlaven tomac   unit testing in angular js
Slaven tomac unit testing in angular js
 
In the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: GradleIn the Brain of Hans Dockter: Gradle
In the Brain of Hans Dockter: Gradle
 
Inside the JVM - Performance & Garbage Collector Tuning in JAVA
Inside the JVM - Performance & Garbage Collector Tuning in JAVA Inside the JVM - Performance & Garbage Collector Tuning in JAVA
Inside the JVM - Performance & Garbage Collector Tuning in JAVA
 
Continuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScriptContinuous Integration for front-end JavaScript
Continuous Integration for front-end JavaScript
 
My name is Trinidad
My name is TrinidadMy name is Trinidad
My name is Trinidad
 
16 ARTIFACTS TO CAPTURE WHEN YOUR CONTAINER APPLICATION IS IN TROUBLE
16 ARTIFACTS TO CAPTURE WHEN YOUR CONTAINER APPLICATION IS IN TROUBLE16 ARTIFACTS TO CAPTURE WHEN YOUR CONTAINER APPLICATION IS IN TROUBLE
16 ARTIFACTS TO CAPTURE WHEN YOUR CONTAINER APPLICATION IS IN TROUBLE
 
Python + GDB = Javaデバッガ
Python + GDB = JavaデバッガPython + GDB = Javaデバッガ
Python + GDB = Javaデバッガ
 
Eric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build systemEric Lafortune - The Jack and Jill build system
Eric Lafortune - The Jack and Jill build system
 
DevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on KubernetesDevoxxUK: Optimizating Application Performance on Kubernetes
DevoxxUK: Optimizating Application Performance on Kubernetes
 
OSCON2012TroubleShootJava
OSCON2012TroubleShootJavaOSCON2012TroubleShootJava
OSCON2012TroubleShootJava
 
Java performance
Java performanceJava performance
Java performance
 
Performance tuning jvm
Performance tuning jvmPerformance tuning jvm
Performance tuning jvm
 

Plus de Petr Zapletal

Plus de Petr Zapletal (10)

Change Data Capture - Scale by the Bay 2019
Change Data Capture - Scale by the Bay 2019Change Data Capture - Scale by the Bay 2019
Change Data Capture - Scale by the Bay 2019
 
Real World Serverless
Real World ServerlessReal World Serverless
Real World Serverless
 
Reactive mistakes - ScalaDays Chicago 2017
Reactive mistakes -  ScalaDays Chicago 2017Reactive mistakes -  ScalaDays Chicago 2017
Reactive mistakes - ScalaDays Chicago 2017
 
Reactive mistakes reactive nyc
Reactive mistakes   reactive nycReactive mistakes   reactive nyc
Reactive mistakes reactive nyc
 
Distributed Stream Processing - Spark Summit East 2017
Distributed Stream Processing - Spark Summit East 2017Distributed Stream Processing - Spark Summit East 2017
Distributed Stream Processing - Spark Summit East 2017
 
Top Mistakes When Writing Reactive Applications - Scala by the Bay 2016
Top Mistakes When Writing Reactive Applications - Scala by the Bay 2016Top Mistakes When Writing Reactive Applications - Scala by the Bay 2016
Top Mistakes When Writing Reactive Applications - Scala by the Bay 2016
 
Distributed Real-Time Stream Processing: Why and How 2.0
Distributed Real-Time Stream Processing:  Why and How 2.0Distributed Real-Time Stream Processing:  Why and How 2.0
Distributed Real-Time Stream Processing: Why and How 2.0
 
Distributed real time stream processing- why and how
Distributed real time stream processing- why and howDistributed real time stream processing- why and how
Distributed real time stream processing- why and how
 
Spark Concepts - Spark SQL, Graphx, Streaming
Spark Concepts - Spark SQL, Graphx, StreamingSpark Concepts - Spark SQL, Graphx, Streaming
Spark Concepts - Spark SQL, Graphx, Streaming
 
MLlib and Machine Learning on Spark
MLlib and Machine Learning on SparkMLlib and Machine Learning on Spark
MLlib and Machine Learning on Spark
 

Dernier

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Dernier (20)

Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
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
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 

Adopting GraalVM - Scala eXchange London 2018