: Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running...
Transcript of : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running...
: Run Programs Faster Anywhere2. __________________1. ___________ 3. ___________________
Yudi Zheng
Senior Researcher Graal Compiler Team, Oracle Labs Apr. 2019
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement The following is intended to outline our general product direction. It is intended forinformation purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle.
�3
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
About Me • Yudi Zheng ( 郑⾬雨迪) • [email protected] • Graal compiler team, Oracle Labs Zurich • Research area: dynamic compilation, program analysis
�4
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �5
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �6
X
Copyright © 2018, Oracle and/or its affiliates. All rights reserved. |
x
7
2015
2016
2017
2018
2019
Java 10 highlights Graal
JEP 243: Java-Level JVM Compiler Interface
JEP 295: Ahead-of-Time Compilation
JEP 317: Experimental Java-Based JIT Compiler
Java “We’llstartwiththesoupagain.”
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �8
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
JVM
Java Execution in a Nutshell
�9
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
JVM
Java Execution in a Nutshell
�10
javac compiler
Clojure
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
JVM
Java Execution in a Nutshell
�11
Interpreter JIT Compiler
0:00 0:03
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
JVM
Java Execution in a Nutshell
�12
Interpreter C1 C2Graal
0:00 1:000:03
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
JVM
Java Execution in a Nutshell
�13
Interpreter C2
Graal
0:00 0:03
C1
1:00
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Graal & C2: Escape Analysis
�14
int add(int x, int y) { return new Add(x, y).apply();
}
int add(int x, int y) { return x+y;
}
class Add {int x, y;Add(int x, int y) {
this.x=x; this.y=y; }int apply() {return x+y;}
}
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Graal-Only: Partial Escape Analysis
�15
static Add cachedOp;
int add(int x, int y, boolean cond) {
Add op = new Add(x, y); if (cond)
cachedOp = op; return op.apply();
}
static Add cachedOp;
int add(int x, int y, boolean cond) {
if (cond){ Add op = new Add(x, y); cachedOp = op;
} return x + y;
}
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Peak Performance: Graal as JIT Compiler Performance Speedup Relative to HotSpot/C2
0
0.5
1
1.5
Numeric Java Java Data processing Scala
1.461.4
1.081.01
1.161.140.99
0.88
C2/Java 8GraalVM CE GraalVM EE
�16
* Numeric Java: numeric benchmarks from SPECjvm2008* Java: real-life applications from SPECjvm2008, DaCapo, Renaissance
* Data processing: Java8 streams, Spark, ML algorithms from Renaissance* Scala: Scala applications from ScalaBench, Renaissance
inJava
“Can’tIstayalittlelonger?I’msohappyhere.”
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �17
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �18
The War of Programming Languages
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �19
Enhance Your Favorite Language… • Project Amber • JEP 286: Local-Variable Type Inference (JDK 10) • JEP 325: Switch Expressions (preview, JDK 12)
• Project Loom: Fibers, Continuations and Tail-Calls for the JVM
• Project Panama: Interconnecting JVM and native code
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �20
… or Polyglot!
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
and Its Ecosystem
�21
HotSpot VM Graal
Truffle Languages
Truffle Framework JVM Languages
Clojure <——— Polyglot API ———>
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Performance: Raytracing on R
Performance Speedup Relative to GNU-R 3.4.0
0
2
4
6
8
10
GNU-R + Fortran
GraalVM CE + Fortran
GraalVM EE + Fortran
GNU-R GraalVM CE GraalVM EE
8.47
5.09
0.23
3.213.08
1
�22
* ref https://medium.com/graalvm/faster-r-with-fastr-4b8db0e0dceb
“Nowisyourchancetoescape!” JVM
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �23
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �24
standalone
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Substrate VM
�25
Java Application
JDK
Substrate VM
Application running without dependency on JDK
and without Java class loading
Reachable methods, fields, and classes
All Java classes from application, JDK,and Substrate VM
Static Analysis Ahead-of-Time
Compilation
ELF / MachO Binary
Machine Code
Initial Heap
DWARF Info Closed-World Assumption
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
"Hello World" in C, Java
�26
C
101 011
RAM
<10 ms
450 KB
100 K
Java/JVM
101 011
RAM
40 ms
24 MB
140 M
Java/SVM
101 011
RAM
<10 ms
850 KB
220 K
* Operating system: Linux; Time, Memory: /usr/bin/time ... ; Instructions: valgrind --tool=callgrind ...;
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
"Hello World" in JavaScript
�27
V8
101 011
RAM
<10 ms
18 MB
10 M
Nashorn
101 011
RAM
450 ms
56 MB
N/A
SVM
101 011
RAM
<10 ms
4 MB
520 K
* Operating system: Linux; Time, Memory: /usr/bin/time ... ; Instructions: valgrind --tool=callgrind ...;
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
and Its Ecosystem
�28
HotSpot VM Graal
Truffle Languages
Truffle Framework JVM Languages
Clojure
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
and Its Ecosystem
�29
HotSpot VM Graal
Truffle Languages
Truffle Framework
Substrate VM
JVM Languages
Clojure
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
and Its Ecosystem
�30
Truffle Languages
Truffle Framework
Substrate VM
JVM Languages
Standalone
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
AOT-Graal: libgraal.so
�31
HotSpot VM Graal
Truffle Languages
Truffle Framework JVM Languages
Clojure
libgraal.so
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
Get Started!
Documentation https://www.graalvm.org/
https://medium.com/graalvm
Open source on GitHub https://github.com/oracle/graal
Enterprise Release Search for “OTN Graal”
�32
“Takeiteasyandavoidexcitement.”
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �33