GraalVM Scott Lynn Director of Product Strategy, Oracle Linux Confidential – Oracle Internal/Restricted/Highly Restricted
This is a Safe Harbor Front slide, one of two Safe Harbor Statement slides included in this template. One of the Safe Harbor slides must be used if your presentation covers material affected by Oracle’s Revenue Recognition Policy To learn more about this policy, e-mail: Revrec-americasiebc_us@oracle.com For internal communication, Safe Harbor Statements are not required. However, there is an applicable disclaimer (Exhibit E) that should be used, found in the Oracle Revenue Recognition Policy for Future Product Communications. Copy and paste this link into a web browser, to find out more information. http://my.oracle.com/site/fin/gfo/GlobalProcesses/cnt452504.pdf For all external communications such as press release, roadmaps, PowerPoint presentations, Safe Harbor Statements are required. You can refer to the link mentioned above to find out additional information/disclaimers required depending on your audience.
You need to execute strategy faster and respond faster to customer and business needs Budgetary cuts mean you need to drive productivity up and drive down costs In the face of nearly constant change, you have ever increasing security and compliance requirements Agile World
Capital Expense to Subscription Private Data Centers & Web IOT Machine Learning/AI Cloud Shifting from a capital expense model to subscription model <click> Private Data Centers and Client/Web-based apps to IOT & Cloud It’s allows dynamic data centers. No longer have to build a data center to meet your anticipated maximum usage. You buy what you need, when you need it. This is reducing hardware, power, cooling, and real estate costs. It allows to execute strategy faster and respond faster to customer and business needs You are able to drive productivity up and drive down costs in the face of ever shrinking budgets
Plethora of Languages
Cloud software is demanding more efficient runtimes Move from VMs to containers allows more sharing between apps (e.g. the OS) * Source: ZDNet.com: “What is Docker and why is it so darn popular?”, May 7, 2017
Microservices are a big reason for interest in containers More flexible scale-out as you replicate just the parts of your app that are needed Containers enable microservices since they have lower overhead per copy You can fit hundreds of containers on a laptop Microservices share common code among apps in the enterprise written in any language Confidential – Oracle Internal/Restricted/Highly Restricted
Host Operating System & Container Virtualization Apps in Containers Language Runtimes Are Generally Pretty Big “Hello World” in Java: 24 MB “Hello World” in JavaScript (V8): 18 MB “Hello World” in Ruby/Rails: 8 MB App A1 Java VM Java Libs JBoss App B1 App C1 App D2 App A2 App A3 App B2 App D1 Ruby Ruby Libs Rails Python Python Libs JavaScript JS Libs Node.js Host Operating System & Container Virtualization
Host Operating System & Container Virtualization The Same Services Why Not Just Share them? GC Coupling Don’t run in JavaVM or not well Interpreter JIT Compiler Garbage Collector All applications need such services, so why can’t I share such them across different applications? Java application servers (like JBoss or WebLogic) did this, but they have a few problems The biggest issue is “GC Coupling”: if multiple applications share a heap, and if one of them triggers a garbage collection, it can stop the other applications in that runtime Very bad for most multitenant scenarios The second issue was that a lot of applications don’t run on the Java VM (or at least not very well), so they don’t solve the multitenant app problem as well as Docker does App A1 Java VM Java Libs JBoss App B1 App C1 App D2 App A2 App A3 App B2 App D1 Ruby Ruby Libs Rails Python Python Libs JavaScript JS Libs Node.js Host Operating System & Container Virtualization Memory Manager Ruby Ruby Libs Rails Code Cache Threading / Scheduler Network Access Filesystem Access
GraalVM
GraalVM is Polyglot (Multilingual) Virtualization Graal languages are built on the “Truffle” API for constructing interpreters Interpreters define the semantics of the language, and are also used to profile program behavior to guide compilation of frequently-used code (e.g. loops) Truffle is a Java API GraalVM includes multiple language interpreters, and learns the type system and language from what they do in order to generate the compiler Since the interpreters are all implemented in Java, merging them together into a single engine looks the same to Graal as a single (very complicated) language Graal watches Truffle API activity to learn the language Compiled code snippet JavaScript Interpreter Ruby Interpreter R Interpreter Python Interpreter Compiled code snippet GraalVM compiler Compiled code snippet Compiled code snippet Compiled code snippet Compiled code snippet Truffle API Java Runtime
Complete GraalVM architecture Easy! Right? … JavaScript application JavaScript libraries Node.js Ruby application Ruby gems & libraries Rails Compiled code snippet JavaScript Interpreter Ruby Interpreter R Interpreter Python Interpreter Compiled code snippet GraalVM compiler Compiled code snippet Compiled code snippet Compiled code snippet Compiled code snippet Truffle API Java Runtime
Complete GraalVM architecture Doesn’t this break security? What do you do about native code? … JavaScript application JavaScript libraries Node.js Ruby application Ruby gems & libraries Rails Compiled code snippet JavaScript Interpreter Ruby Interpreter R Interpreter Python Interpreter Compiled code snippet GraalVM compiler Compiled code snippet Compiled code snippet Compiled code snippet Compiled code snippet Truffle API Java Runtime
Complete GraalVM architecture … JavaScript application JavaScript libraries Node.js Ruby application Ruby gems & libraries Rails R native libraries Node.js native libs Ruby/Rails native libs Compiled code snippet JavaScript Interpreter Ruby Interpreter R Interpreter Python Interpreter LLVM .bc Interpreter Compiled code snippet GraalVM compiler Compiled code snippet Compiled code snippet Compiled code snippet Compiled code snippet Truffle API Java Runtime 15
Complete GraalVM architecture JavaScript application Ruby application … R native libraries Node.js native libs Ruby/Rails native libs When GraalVM is embedded in the HotSpot JVM, you can run Java apps directly on the JVM without Truffle In this case, JVM uses Graal as a Java bytecode compiler via the JVM Compiler Interface (JVMCI, or JEP 243) Note: Truffle gives an “Abstract Syntax Tree” (language-agnostic representation of work to do) to Graal, not Java bytecodes JavaScript libraries Ruby gems & libraries eval("application/x-ruby", "def add(a, b) a + b; end;"); Node.js Rails Truffle Polyglot API JavaScript Interpreter Ruby Interpreter R Interpreter LLVM .bc Interpreter Compiled code snippet Compiled code snippet Truffle API Java application Compiled code snippet Graal compiler Truffle CI Compiled code snippet Compiled code snippet JavaVM Runtime Compiled code snippet JVMCI Threads / Scheduler Filesystem Network GC / heap Code cache
GraalVM embedded in the Oracle Database Embedding GraalVM allows substitution of the underlying engine’s service layer JavaScript application Ruby application … R native libraries Node.js native libs Ruby/Rails native libs Oracle database takes on many functions of an OS: scheduling, resource management, I/O GraalVM allows mixing & matching system components from the underlying runtime JavaScript libraries Ruby gems & libraries eval("application/x-ruby", "def add(a, b) a + b; end;"); Node.js Rails Truffle Polyglot API JavaScript Interpreter Ruby Interpreter R Interpreter LLVM .bc Interpreter Compiled code snippet Compiled code snippet Truffle API Compiled code snippet Graal compiler Truffle CI Compiled code snippet Compiled code snippet GraalVM Runtime GC / heap Code cache Compiled code snippet Oracle RDBMS Runtime Net Filesystem Threads / Scheduler
Host Operating System & Container Virtualization Apps in Containers Language Runtimes Are Generally Pretty Big “Hello World” in Java: 24 MB “Hello World” in JavaScript (V8): 18 MB “Hello World” in Ruby/Rails: 8 MB App A1 App A2 App A3 App B1 App B2 App D1 App D2 Java VM Java Libs JBoss Java VM Java Libs JBoss Java VM Java Libs JBoss Ruby Ruby Libs Rails Ruby Ruby Libs Rails JavaScript JS Libs Node.js JavaScript JS Libs Node.js App C1 Python Python Libs Host Operating System & Container Virtualization
Apps in Containers with Graal Shared runtime Memory management Separate spaces for apps called ”Isolates” Scheduling Code Higher performance applications Higher server density App D1 App D2 App C1 JS Libs App B1 App B2 Python Libs Ruby Libs Node.js Rails App A3 LLVM bc Interpreter Python Interpreter JavaScript Interpreter Ruby Interpreter Truffle API App A1 App A2 Java Runtime Host Operating System & Container Virtualization
Graal Performance Comparison vs the state of the art special-purpose implementation Average across a wide range of benchmarks Some kinds of code (e.g. code with lots of allocations & GC, network/file access) will not be improved More abstract & complex code has more opportunities for improved analysis and sees larger benefits Talk about startup performance Give clear set of advantages: Startup time Higher density Advantages for serverless Range Speedup (Geomean) Comparison Versus Java 0.8x - 2x 1.1x JDK8 Scala 1.3x JavaScript 0.5x 1.5x 1.05x Google V8 Ruby 1x 100x 5x JRuby R GNU R C/C++ 0.4x 1.2x 0.9x LLVM native
Application Level Performance What about real applications, not just benchmarks According to Twitter, Graal runs Twitter 25% faster than Java8 WebLogic Server has 10% better throughput running basic web pages
Polyglot Demo
PolyGlot Demo Test.java public class Test { public static String getString() { return "Hello from Java! <br> "; } }
PolyGlot Demo server.js 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! ' // Using Java standard library classes text += BigInteger.valueOf(2).pow(100).toString(16) text += ' ' // Using custom Java class text += Java.type('Test').getString() // Using R methods to return arrays text += Interop.eval('application/x-r', 'runif(1000)')[0] // Using R interoperability to create graphs text += Interop.eval('application/x-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) }) app.listen(3000, function () { console.log('Example app listening on port 3000!')
PolyGlot Demo server.js 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! '
PolyGlot Demo (2) server.js // Using Java standard library classes text += BigInteger.valueOf(2).pow(100).toString(16) text += ' ' // Using custom Java class text += Java.type('Test').getString()
PolyGlot Demo (3) server.js // Using R methods to return arrays text += Interop.eval('application/x-r', 'runif(1000)')[0]
PolyGlot Demo (4) server.js // Using R interoperability to create graphs text += Interop.eval('application/x-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) })
PolyGlot Demo (5) server.js app.listen(3000, function () { console.log('Example app listening on port 3000!') })
Stream Demo
Learn More or Get Involved GraalVM at Oracle GraalVM at Git
Q&A Confidential – Oracle Internal/Restricted/Highly Restricted
This is a Safe Harbor Front slide, one of two Safe Harbor Statement slides included in this template. One of the Safe Harbor slides must be used if your presentation covers material affected by Oracle’s Revenue Recognition Policy To learn more about this policy, e-mail: Revrec-americasiebc_us@oracle.com For internal communication, Safe Harbor Statements are not required. However, there is an applicable disclaimer (Exhibit E) that should be used, found in the Oracle Revenue Recognition Policy for Future Product Communications. Copy and paste this link into a web browser, to find out more information. http://my.oracle.com/site/fin/gfo/GlobalProcesses/cnt452504.pdf For all external communications such as press release, roadmaps, PowerPoint presentations, Safe Harbor Statements are required. You can refer to the link mentioned above to find out additional information/disclaimers required depending on your audience.
Graal A Modern Virtual Environment for the Agile Age Makes DevOps applications simpler to develop and deploy DevOps means multiple languages Removes barriers between language environments Reduces development cost Removes language requirements Higher performance for most applications 20% to 5x faster for most applications Up to 2x faster for applications using SQL Embed GraalVM into data engines (mySQL, REDIS, Oracle Database) Open Community innovation SQL performance is 2x to as much as 20x faster, using 2x. Confidential – Oracle Highly Restricted
What is GraalVM? Open source polyglot language virtualization environment Polyglot compiler (Truffle) Able to understand and use multiple languages (Polyglot) Java, JavaScript, Node, Ruby, R, Python (coming), C/C++ (coming) Runtime Community version uses JavaVM Enterprise/embedded version has its own runtime (SubstrateVM) RDBMS query compiler/optimizer (Walnut) Confidential – Oracle Highly Restricted
Why GraalVM? The Problem Cloud enterprises today already have “legacy” code E.g. Twitter is written in Ruby and is currently being rewritten Have to choose a small set of languages for app development Python, C/C++, Java, JavaScript, Node.js, R, Ruby… There are too many to just use them all Every language has its own runtime More runtimes = more administration, testing, infrastructure costs Crossing boundaries is costly API boundaries mean translation time Bugs, CPU cycles, more testing Not future proof Evolving language requirements can lead to even more legacy code Confidential – Oracle Highly Restricted
Why GraalVM? The Solution Cloud enterprises today already have “legacy” code Polyglot virtualization environment Legacy and new code run in the same environment Have to choose a small set of languages for app development Use whatever languages Graal understands Developers use the right tool for the problem Every language has its own runtime 1 runtime environment Crossing boundaries is costly API boundaries removed/reduced Not future-proof Adopt new languages while re-using existing code and libraries Confidential – Oracle IHighly Restricted