SlideShare una empresa de Scribd logo
1 de 16
Descargar para leer sin conexión
Manfredi Giordano 09/07/2020
GraalVM
JVM development for the 21st century
1
Agenda
• Developing for the JVM
• Main GraalVM features
• GraalVM in practice
• GraalVM vs Scala Native
• Demo
2
DevelopingfortheJVM
• Write once, run anywhere
• The Java Virtual Machine is an execution engine for Java bytecode
• Write once, debug anywhere
• Large memory footprint, slow startup time, slow execution
• Exacerbated with the shift to modern computation & deployment standards
• Microservices, containers: higher in number, smaller in size …
• Cloud computing: transient resources …
Joys and sorrows
3
Johannes Brüderl – source
“While it’s certainly bearable to have 100MB+
large hello world applications in 2018, it’s just
weak if I can have a 6MB Go binary”
4
Meet GraalVM
5
Renato Athaydes – source
“A 7MB native-image Java app that runs in
30ms and uses only 4MB of RAM!”
6
MainGraalVMfeatures
• Modern compiler, turning JVM applications into self-contained binaries
• Drop JRE -> fast startup, low memory footprint
• native-image compiler, taking bytecode as input
• Polyglot applications: interoperability of multiple languages
• Universal Virtual Machine: JavaScript, Python, Ruby, C, R out of the box
Why should we care
7
const express = require('express')
const app = express()
const BigInteger = Java.type('java.math.BigInteger')
app.get('/', function (req, res) {
var text = 'Hello World from Graal.js!<br> '
// Using Java standard library classes
text += BigInteger.valueOf(10).pow(100)
.add(BigInteger.valueOf(43)).toString() + '<br>'
// Using R interoperability to create graphs
text += Polyglot.eval('R',
`svg();
require(lattice);
x <- 1:100
y <- sin(x/10)
z <- cos(x^1.3/(runif(1)*5+10))
print(cloud(x~y*z, main="cloud plot"))
grDevices:::svg.off()
`);
res.send(text)
})
8
9
const express = require('express')
const app = express()
app.get('/', function (req, res) {
var text = 'Hello World from Graal.js!<br> '
// Using Java standard library classes
text +=
// Using R interoperability to create graphs
text += Polyglot.eval('R',
`
`);
res.send(text)
})
Java
JavaScript
svg();
require(lattice);
x <- 1:100
y <- sin(x/10)
z <- cos(x^1.3/(runif(1)*5+10))
print(cloud(x~y*z, main="cloud plot"))
grDevices:::svg.off()
const BigInteger = Java.type('java.math.BigInteger')
BigInteger.valueOf(10).pow(100)
.add(BigInteger.valueOf(43)).toString() + '<br>'
R
MainGraalVMfeatures
• Modern compiler, turning JVM applications into self-contained binaries
• Drop JRE -> fast startup, low memory footprint
• native-image compiler, taking bytecode as input
• Polyglot applications: interoperability of multiple languages
• Universal Virtual Machine: JavaScript, Python, Ruby, C, R out of the box
• Implement your own language
• Truffle Language Implementation Framework
• Write once, compile anywhere
Why should we care
10
GraalVMinpractice
• Ahead-Of-Time (AOT) compilation
• Performance trade-off: moves the complexity / overhead from the runtime to the
compilation
• Closed-world analysis of all the bytecode that will be executed at run-time
• Some limitations:
• Incompatible with dynamically created bytecode – e.g. reflection, dynamic class
loading, metaprogramming
• Other interpreted languages are not compiled
Native Image
11
Technicaldetails
• Based on Oracle’s HotSpot
• Currently supports Java 8 + Java 11
• GraalVM Community vs GraalVM Enterprise
• Enterprise recommended for production applications
• native-image -jar target/test.jar
• sbt graalvm-native-image:packageBin
• Fallback AOT-compiled images requiring a JRE
Native Image
12
Competitor: Scala Native
13
GraalVMvsScalaNative
• Applies to the whole JVM ecosystem
• Java, Scala, Kotlin, Clojure, …
• Bigger app binaries size
• Bigger community, bigger sponsor: Oracle
• Framework support, related projects
• Spring, Quarkus, sbt-native-packager
• native-image is early adopter technology
• Hard to configure it right
• Polyglot features
14
• Only applies to Scala
• Possibly more optimised?
• Smaller community, smaller sponsor:
Scala Center
• Smaller libraries support
• sbt-crossproject
• Not updated for a while, now restarted
• Only supports Scala 2.11
• Interoperability with C
References1/2
• GraalVM
https://www.graalvm.org
https://github.com/oracle/graal
• GraalVM Enterprise first production-ready release
https://blogs.oracle.com/graalvm/announcement
• GraalVM’s AOT compiler limitations
https://www.graalvm.org/docs/reference-manual/native-image/#aot-compilation-limitations
• sbt-native-packager's GraalVM Native Image Plugin
https://sbt-native-packager.readthedocs.io/en/stable/formats/graalvm-native-image.html
• Truffle Language Implementation Framework
https://github.com/oracle/graal/blob/master/truffle/README.md
• Twitter running GraalVM in production
https://youtu.be/pR5NDkIZBOA
15
References2/2
• Scala Native
https://scala-native.readthedocs.io/en/latest/index.html
https://github.com/scala-native/scala-native
• Scala Native next steps
https://contributors.scala-lang.org/t/scala-native-next-steps/4216
• A 7MB native-image Java app that runs in 30ms and uses only 4MB of RAM!
https://sites.google.com/a/athaydes.com/renato-athaydes/posts/a7mbnative-
imagejavaappthatrunsin30msandusesonly4mbofram
• Javalin web framework with GraalVM
https://javalin.io/2018/09/27/javalin-graalvm-example.html
• Example benchmarks for REST APIs with GraalVM
https://www.rubix.nl/blogs/graalvm-native-images-rest-api/
• Top 10 Things To Do With GraalVM
https://medium.com/graalvm/graalvm-ten-things-12d9111f307d
16

Más contenido relacionado

La actualidad más candente

Openstack Summit HK - Ceph defacto - eNovance
Openstack Summit HK - Ceph defacto - eNovanceOpenstack Summit HK - Ceph defacto - eNovance
Openstack Summit HK - Ceph defacto - eNovance
eNovance
 

La actualidad más candente (20)

Choosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
Choosing Right Garbage Collector to Increase Efficiency of Java Memory UsageChoosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
Choosing Right Garbage Collector to Increase Efficiency of Java Memory Usage
 
Openstack Summit HK - Ceph defacto - eNovance
Openstack Summit HK - Ceph defacto - eNovanceOpenstack Summit HK - Ceph defacto - eNovance
Openstack Summit HK - Ceph defacto - eNovance
 
Going deep (learning) with tensor flow and quarkus
Going deep (learning) with tensor flow and quarkusGoing deep (learning) with tensor flow and quarkus
Going deep (learning) with tensor flow and quarkus
 
Container orchestration: the cold war - Giulio De Donato - Codemotion Rome 2017
Container orchestration: the cold war - Giulio De Donato - Codemotion Rome 2017Container orchestration: the cold war - Giulio De Donato - Codemotion Rome 2017
Container orchestration: the cold war - Giulio De Donato - Codemotion Rome 2017
 
Vinetalk: The missing piece for cluster managers to enable accelerator sharing
Vinetalk: The missing piece for cluster managers to enable accelerator sharingVinetalk: The missing piece for cluster managers to enable accelerator sharing
Vinetalk: The missing piece for cluster managers to enable accelerator sharing
 
Integrating Puppet with Cloud Infrastructures-Remco Overdijk
Integrating Puppet with Cloud Infrastructures-Remco OverdijkIntegrating Puppet with Cloud Infrastructures-Remco Overdijk
Integrating Puppet with Cloud Infrastructures-Remco Overdijk
 
Distributed Systems explained (with NodeJS) - Bruno Bossola, JUG Torino
Distributed Systems explained (with NodeJS) - Bruno Bossola, JUG TorinoDistributed Systems explained (with NodeJS) - Bruno Bossola, JUG Torino
Distributed Systems explained (with NodeJS) - Bruno Bossola, JUG Torino
 
Containerised ASP.NET Core apps with Kubernetes
Containerised ASP.NET Core apps with KubernetesContainerised ASP.NET Core apps with Kubernetes
Containerised ASP.NET Core apps with Kubernetes
 
Fission: Serverless Functions for Kubernetes
Fission: Serverless Functions for KubernetesFission: Serverless Functions for Kubernetes
Fission: Serverless Functions for Kubernetes
 
Developing Microservices with Apache Camel
Developing Microservices with Apache CamelDeveloping Microservices with Apache Camel
Developing Microservices with Apache Camel
 
Micro services infrastructure with AWS and Ansible
Micro services infrastructure with AWS and AnsibleMicro services infrastructure with AWS and Ansible
Micro services infrastructure with AWS and Ansible
 
Wido den hollander cloud stack and ceph
Wido den hollander   cloud stack and cephWido den hollander   cloud stack and ceph
Wido den hollander cloud stack and ceph
 
EVCache at Netflix
EVCache at NetflixEVCache at Netflix
EVCache at Netflix
 
Using Kafka to scale database replication
Using Kafka to scale database replicationUsing Kafka to scale database replication
Using Kafka to scale database replication
 
DevEx | there’s no place like k3s
DevEx | there’s no place like k3sDevEx | there’s no place like k3s
DevEx | there’s no place like k3s
 
Distributed Tensorflow with Kubernetes - data2day - Jakob Karalus
Distributed Tensorflow with Kubernetes - data2day - Jakob KaralusDistributed Tensorflow with Kubernetes - data2day - Jakob Karalus
Distributed Tensorflow with Kubernetes - data2day - Jakob Karalus
 
Getting started with Riak in the Cloud
Getting started with Riak in the CloudGetting started with Riak in the Cloud
Getting started with Riak in the Cloud
 
Building a derived data store using Kafka
Building a derived data store using KafkaBuilding a derived data store using Kafka
Building a derived data store using Kafka
 
141204 upload
141204 upload141204 upload
141204 upload
 
Monitoring, the Prometheus Way - Julius Voltz, Prometheus
Monitoring, the Prometheus Way - Julius Voltz, Prometheus Monitoring, the Prometheus Way - Julius Voltz, Prometheus
Monitoring, the Prometheus Way - Julius Voltz, Prometheus
 

Similar a GraalVM

Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
catherinewall
 

Similar a GraalVM (20)

Peru JUG Micronaut & GraalVM
Peru JUG Micronaut & GraalVMPeru JUG Micronaut & GraalVM
Peru JUG Micronaut & GraalVM
 
Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
 
GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18GraalVM - OpenSlava 2019-10-18
GraalVM - OpenSlava 2019-10-18
 
GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22GraalVM - MadridJUG 2019-10-22
GraalVM - MadridJUG 2019-10-22
 
Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009Dynamic Languages Web Frameworks Indicthreads 2009
Dynamic Languages Web Frameworks Indicthreads 2009
 
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
 
Gradle
GradleGradle
Gradle
 
Tips For Maintaining OSS Projects
Tips For Maintaining OSS ProjectsTips For Maintaining OSS Projects
Tips For Maintaining OSS Projects
 
Simple tweaks to get the most out of your JVM
Simple tweaks to get the most out of your JVMSimple tweaks to get the most out of your JVM
Simple tweaks to get the most out of your JVM
 
Cannibalising The Google App Engine
Cannibalising The  Google  App  EngineCannibalising The  Google  App  Engine
Cannibalising The Google App Engine
 
Simple tweaks to get the most out of your jvm
Simple tweaks to get the most out of your jvmSimple tweaks to get the most out of your jvm
Simple tweaks to get the most out of your jvm
 
Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]Java script nirvana in netbeans [con5679]
Java script nirvana in netbeans [con5679]
 
Java Future S Ritter
Java Future S RitterJava Future S Ritter
Java Future S Ritter
 
Commit to excellence - Java in containers
Commit to excellence - Java in containersCommit to excellence - Java in containers
Commit to excellence - Java in containers
 
Migrating to Java 11
Migrating to Java 11Migrating to Java 11
Migrating to Java 11
 
Polyglot Applications with GraalVM
Polyglot Applications with GraalVMPolyglot Applications with GraalVM
Polyglot Applications with GraalVM
 
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
 
Drools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentationDrools, jBPM OptaPlanner presentation
Drools, jBPM OptaPlanner presentation
 
Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...
Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...
Run Scala Faster with GraalVM on any Platform / GraalVMで、どこでもScalaを高速実行しよう by...
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 

Último

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
mphochane1998
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
Epec Engineered Technologies
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
MayuraD1
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
HenryBriggs2
 

Último (20)

Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
Learn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic MarksLearn the concepts of Thermodynamics on Magic Marks
Learn the concepts of Thermodynamics on Magic Marks
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments""Lesotho Leaps Forward: A Chronicle of Transformative Developments"
"Lesotho Leaps Forward: A Chronicle of Transformative Developments"
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
School management system project Report.pdf
School management system project Report.pdfSchool management system project Report.pdf
School management system project Report.pdf
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 

GraalVM

  • 1. Manfredi Giordano 09/07/2020 GraalVM JVM development for the 21st century 1
  • 2. Agenda • Developing for the JVM • Main GraalVM features • GraalVM in practice • GraalVM vs Scala Native • Demo 2
  • 3. DevelopingfortheJVM • Write once, run anywhere • The Java Virtual Machine is an execution engine for Java bytecode • Write once, debug anywhere • Large memory footprint, slow startup time, slow execution • Exacerbated with the shift to modern computation & deployment standards • Microservices, containers: higher in number, smaller in size … • Cloud computing: transient resources … Joys and sorrows 3
  • 4. Johannes Brüderl – source “While it’s certainly bearable to have 100MB+ large hello world applications in 2018, it’s just weak if I can have a 6MB Go binary” 4
  • 6. Renato Athaydes – source “A 7MB native-image Java app that runs in 30ms and uses only 4MB of RAM!” 6
  • 7. MainGraalVMfeatures • Modern compiler, turning JVM applications into self-contained binaries • Drop JRE -> fast startup, low memory footprint • native-image compiler, taking bytecode as input • Polyglot applications: interoperability of multiple languages • Universal Virtual Machine: JavaScript, Python, Ruby, C, R out of the box Why should we care 7
  • 8. const express = require('express') const app = express() const BigInteger = Java.type('java.math.BigInteger') app.get('/', function (req, res) { var text = 'Hello World from Graal.js!<br> ' // Using Java standard library classes text += BigInteger.valueOf(10).pow(100) .add(BigInteger.valueOf(43)).toString() + '<br>' // Using R interoperability to create graphs text += Polyglot.eval('R', `svg(); require(lattice); x <- 1:100 y <- sin(x/10) z <- cos(x^1.3/(runif(1)*5+10)) print(cloud(x~y*z, main="cloud plot")) grDevices:::svg.off() `); res.send(text) }) 8
  • 9. 9 const express = require('express') const app = express() app.get('/', function (req, res) { var text = 'Hello World from Graal.js!<br> ' // Using Java standard library classes text += // Using R interoperability to create graphs text += Polyglot.eval('R', ` `); res.send(text) }) Java JavaScript svg(); require(lattice); x <- 1:100 y <- sin(x/10) z <- cos(x^1.3/(runif(1)*5+10)) print(cloud(x~y*z, main="cloud plot")) grDevices:::svg.off() const BigInteger = Java.type('java.math.BigInteger') BigInteger.valueOf(10).pow(100) .add(BigInteger.valueOf(43)).toString() + '<br>' R
  • 10. MainGraalVMfeatures • Modern compiler, turning JVM applications into self-contained binaries • Drop JRE -> fast startup, low memory footprint • native-image compiler, taking bytecode as input • Polyglot applications: interoperability of multiple languages • Universal Virtual Machine: JavaScript, Python, Ruby, C, R out of the box • Implement your own language • Truffle Language Implementation Framework • Write once, compile anywhere Why should we care 10
  • 11. GraalVMinpractice • Ahead-Of-Time (AOT) compilation • Performance trade-off: moves the complexity / overhead from the runtime to the compilation • Closed-world analysis of all the bytecode that will be executed at run-time • Some limitations: • Incompatible with dynamically created bytecode – e.g. reflection, dynamic class loading, metaprogramming • Other interpreted languages are not compiled Native Image 11
  • 12. Technicaldetails • Based on Oracle’s HotSpot • Currently supports Java 8 + Java 11 • GraalVM Community vs GraalVM Enterprise • Enterprise recommended for production applications • native-image -jar target/test.jar • sbt graalvm-native-image:packageBin • Fallback AOT-compiled images requiring a JRE Native Image 12
  • 14. GraalVMvsScalaNative • Applies to the whole JVM ecosystem • Java, Scala, Kotlin, Clojure, … • Bigger app binaries size • Bigger community, bigger sponsor: Oracle • Framework support, related projects • Spring, Quarkus, sbt-native-packager • native-image is early adopter technology • Hard to configure it right • Polyglot features 14 • Only applies to Scala • Possibly more optimised? • Smaller community, smaller sponsor: Scala Center • Smaller libraries support • sbt-crossproject • Not updated for a while, now restarted • Only supports Scala 2.11 • Interoperability with C
  • 15. References1/2 • GraalVM https://www.graalvm.org https://github.com/oracle/graal • GraalVM Enterprise first production-ready release https://blogs.oracle.com/graalvm/announcement • GraalVM’s AOT compiler limitations https://www.graalvm.org/docs/reference-manual/native-image/#aot-compilation-limitations • sbt-native-packager's GraalVM Native Image Plugin https://sbt-native-packager.readthedocs.io/en/stable/formats/graalvm-native-image.html • Truffle Language Implementation Framework https://github.com/oracle/graal/blob/master/truffle/README.md • Twitter running GraalVM in production https://youtu.be/pR5NDkIZBOA 15
  • 16. References2/2 • Scala Native https://scala-native.readthedocs.io/en/latest/index.html https://github.com/scala-native/scala-native • Scala Native next steps https://contributors.scala-lang.org/t/scala-native-next-steps/4216 • A 7MB native-image Java app that runs in 30ms and uses only 4MB of RAM! https://sites.google.com/a/athaydes.com/renato-athaydes/posts/a7mbnative- imagejavaappthatrunsin30msandusesonly4mbofram • Javalin web framework with GraalVM https://javalin.io/2018/09/27/javalin-graalvm-example.html • Example benchmarks for REST APIs with GraalVM https://www.rubix.nl/blogs/graalvm-native-images-rest-api/ • Top 10 Things To Do With GraalVM https://medium.com/graalvm/graalvm-ten-things-12d9111f307d 16