SlideShare a Scribd company logo
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

More Related Content

PPTX
Nashorn: JavaScript that doesn't suck - Tomer Gabel, Wix
PDF
Cloud Native Camel Design Patterns
PPTX
Introduction to Napa.js
PPT
Ceph Performance and Optimization - Ceph Day Frankfurt
PDF
Scaling Jakarta EE Applications Vertically and Horizontally with Jelastic PaaS
PDF
High Availability from the DevOps side - OpenStack Summit Portland
PDF
Enterprise Integration for Ethereum
PDF
MariaDB Auto-Clustering, Vertical and Horizontal Scaling within Jelastic PaaS
Nashorn: JavaScript that doesn't suck - Tomer Gabel, Wix
Cloud Native Camel Design Patterns
Introduction to Napa.js
Ceph Performance and Optimization - Ceph Day Frankfurt
Scaling Jakarta EE Applications Vertically and Horizontally with Jelastic PaaS
High Availability from the DevOps side - OpenStack Summit Portland
Enterprise Integration for Ethereum
MariaDB Auto-Clustering, Vertical and Horizontal Scaling within Jelastic PaaS

What's hot (20)

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

Similar to GraalVM (20)

PDF
Peru JUG Micronaut & GraalVM
PDF
Polygot Java EE on the GraalVM
PPTX
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
PDF
GraalVM - OpenSlava 2019-10-18
PDF
GraalVM - MadridJUG 2019-10-22
ODP
Dynamic Languages Web Frameworks Indicthreads 2009
KEY
Google App Engine Java, Groovy and Gaelyk
PDF
Tips For Maintaining OSS Projects
PPTX
Simple tweaks to get the most out of your JVM
PDF
Cannibalising The Google App Engine
PPTX
Simple tweaks to get the most out of your jvm
PPTX
Java script nirvana in netbeans [con5679]
PDF
Java Future S Ritter
PPTX
All you need to know about Spring Boot and GraalVM
PDF
Commit to excellence - Java in containers
PPTX
Migrating to Java 11
PDF
Polyglot Applications with GraalVM
PPTX
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
PDF
Drools, jBPM OptaPlanner presentation
Peru JUG Micronaut & GraalVM
Polygot Java EE on the GraalVM
GOING AOT WITH GRAALVM FOR SPRING BOOT (SPRING IO)
GraalVM - OpenSlava 2019-10-18
GraalVM - MadridJUG 2019-10-22
Dynamic Languages Web Frameworks Indicthreads 2009
Google App Engine Java, Groovy and Gaelyk
Tips For Maintaining OSS Projects
Simple tweaks to get the most out of your JVM
Cannibalising The Google App Engine
Simple tweaks to get the most out of your jvm
Java script nirvana in netbeans [con5679]
Java Future S Ritter
All you need to know about Spring Boot and GraalVM
Commit to excellence - Java in containers
Migrating to Java 11
Polyglot Applications with GraalVM
Getting started with Emscripten – Transpiling C / C++ to JavaScript / HTML5
Drools, jBPM OptaPlanner presentation
Ad

Recently uploaded (20)

PPTX
Sustainable Sites - Green Building Construction
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
PPT on Performance Review to get promotions
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
Well-logging-methods_new................
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPT
Project quality management in manufacturing
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
Sustainable Sites - Green Building Construction
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Lesson 3_Tessellation.pptx finite Mathematics
Foundation to blockchain - A guide to Blockchain Tech
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPT on Performance Review to get promotions
Embodied AI: Ushering in the Next Era of Intelligent Systems
Arduino robotics embedded978-1-4302-3184-4.pdf
Lecture Notes Electrical Wiring System Components
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Well-logging-methods_new................
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
Project quality management in manufacturing
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
CYBER-CRIMES AND SECURITY A guide to understanding

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