Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 17

GraalVM

Scott Lynn
Director of Product Strategy, Oracle Linux

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | Confidential – Oracle Internal/Restricted/Highly Restricted
Use Different Languages for Different Jobs
Long tail of programming languages
Programming Language Popularity
(TOP 20 Languages From May 2017 Tiobe INDEX)
• You run more than a few languages
Java
• Even cloud businesses like Twitter have
“legacy” code Others

• Right tool for the Job: C

– R or Python for data science


– Ruby or JavaScript for front ends C++

– Java or C/C++ for server back ends Python

Scratch C#
PL/SQL
Delphi/Object Pascal VB.NET
MATLAB
JavaScript
Go
Objective-C Assembly language
R PHP
Swift VB Ruby Perl

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 2


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
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. |
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 Java Java
VM VM VM Ruby Ruby JavaScript JavaScript
App C1

Java Libs Java Libs Java Libs Ruby Libs Ruby Libs Python JS Libs JS Libs

Python
JBoss JBoss JBoss Rails Rails Node.js Node.js
Libs

Host Operating System & Container Virtualization

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 4


The Same Services
• Why Not Just Share them?
Interpreter
– GC Coupling
JIT Compiler
– Don’t run in JavaVM or not well
Garbage Collector
App A1 App A2 App A3 App B1 App B2 App D1 App D2
Memory
Java Manager
Java Java
VM VM VM Ruby Ruby JavaScript JavaScript
Code Cache App C1
Threading
Java Libs / Scheduler
Java Libs Java Libs Python
Ruby Libs Ruby Libs JS Libs JS Libs
Network Access
Python
JBoss JBoss
Filesystem Access JBoss Rails Rails Node.js Node.js
Libs

Host Operating System & Container Virtualization

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 5


GraalVM
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 6
GraalVM is Polyglot (Multilingual) Virtualization

Graal watches Truffle API


activity to learn the
language

Compiled
JavaScript Ruby R Python Compiled
Interpreter Interpreter code snippet
Compiled
GraalVM Interpreter Interpreter code snippet
Compiled
code snippet
Compiled
compiler Truffle API code snippet
Compiled
code snippet
Java Runtime code snippet

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 7


Complete GraalVM architecture
Easy! Right?

JavaScript
application
JavaScript
libraries
Ruby
application
Ruby gems
& libraries

Node.js Rails
Compiled
JavaScript Ruby R Python Compiled
Interpreter Interpreter code snippet
Compiled
GraalVM Interpreter Interpreter code snippet
Compiled
code snippet
Compiled
compiler Truffle API code snippet
Compiled
code snippet
Java Runtime code snippet

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 8


Complete GraalVM architecture
• Doesn’t this break security?
• What do you do about native code?

JavaScript
application
JavaScript
libraries
Ruby
application
Ruby gems
& libraries

Node.js Rails
Compiled
JavaScript Ruby R Python Compiled
Interpreter code snippet
Compiled
GraalVM Interpreter Interpreter Interpreter code snippet
Compiled
code snippet
Compiled
compiler Truffle API code snippet
Compiled
code snippet
Java Runtime code snippet

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 9


Complete GraalVM architecture

JavaScript
application
JavaScript
libraries
Ruby
application
Ruby gems
& libraries
… R native
libraries
Node.js
native libs
Ruby/Rails
Node.js Rails native libs
Compiled
JavaScript Ruby R Python LLVM .bc Compiled
Interpreter Interpreter code snippet
Compiled
GraalVM Interpreter Interpreter Interpreter code snippet
Compiled
code snippet
Compiled
compiler Truffle API code snippet
Compiled
code snippet
Java Runtime code snippet

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 10


Complete GraalVM architecture

JavaScript Ruby R native

eval("application/x-ruby",
"def add(a, b) a + b;
application
JavaScript
libraries
application
Ruby gems
& libraries
… libraries
Node.js
native libs
Ruby/Rails
end;");
Node.js Rails native libs
Truffle
Polyglot JavaScript Ruby R LLVM .bc
API
Interpreter Interpreter Interpreter Interpreter
Compiled
Truffle CI Java Compiled
code snippet
Truffle API application codeCompiled
snippet
Graal Compiled
code snippet
JavaVM Runtime Compiled
code snippet
compiler codeCompiled
snippet
JVMCI code snippet
Threads / Scheduler Filesystem Network GC / heap Code cache

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 11


GraalVM embedded in the Oracle Database
Embedding GraalVM allows substitution of the underlying engine’s service layer

JavaScript Ruby R native

eval("application/x-ruby",
"def add(a, b) a + b;
application
JavaScript
libraries
application
Ruby gems
& libraries
… libraries
Node.js
native libs
Ruby/Rails
end;");
Node.js Rails native libs
Truffle
Polyglot JavaScript Ruby R LLVM .bc
API
Interpreter Interpreter Interpreter Interpreter
Compiled
Truffle CI Compiled
code snippet
Truffle API codeCompiled
snippet
Graal Compiled
code snippet
GraalVM Runtime GC / heap Code cache Compiled
code snippet
compiler codeCompiled
snippet
code snippet
Oracle RDBMS Runtime Net Filesystem Threads / Scheduler

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 12


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 Java Java
VM VM VM Ruby Ruby JavaScript JavaScript
App C1

Java Libs Java Libs Java Libs Ruby Libs Ruby Libs Python JS Libs JS Libs

Python
JBoss JBoss JBoss Rails Rails Node.js Node.js
Libs

Host Operating System & Container Virtualization

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 13


Apps in Containers with Graal
• Shared runtime
– Memory management
• Separate spaces for apps called ”Isolates”
– Scheduling
– Code
• Higher performance applications App D1 App D2
App C1
• Higher server density App B1 App B2 JS Libs
Ruby Libs Python
Libs Node.js
Rails
Python
Ruby Interpreter Interpreter
JavaScript Interpreter
App A1 App A2 App A3 Truffle API
Java Runtime
Host Operating System & Container Virtualization

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 14


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

Speedup Comparison
Range (Geomean) Versus
Java 0.8x - 2x 1.1x JDK8
Scala 0.8x - 2x 1.3x JDK8
JavaScript 0.5x - 1.5x 1.05x Google V8
Ruby 1x - 100x 5x JRuby
R 1x - 100x 5x GNU R
C/C++ 0.4x - 1.2x 0.9x LLVM native
Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 15
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

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 16


Polyglot Demo

Copyright © 2017, Oracle and/or its affiliates. All rights reserved. | 17

You might also like