: run programs faster anywher1. 3. e · java application jdk substrate vm application running...
TRANSCRIPT
![Page 1: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/1.jpg)
![Page 2: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/2.jpg)
: 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. |
![Page 3: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/3.jpg)
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
![Page 4: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/4.jpg)
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
![Page 5: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/5.jpg)
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �5
![Page 6: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/6.jpg)
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �6
X
![Page 7: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/7.jpg)
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
![Page 8: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/8.jpg)
Java “We’llstartwiththesoupagain.”
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �8
![Page 9: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/9.jpg)
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
JVM
Java Execution in a Nutshell
�9
![Page 10: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/10.jpg)
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
JVM
Java Execution in a Nutshell
�10
javac compiler
Clojure
![Page 11: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/11.jpg)
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
JVM
Java Execution in a Nutshell
�11
Interpreter JIT Compiler
0:00 0:03
![Page 12: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/12.jpg)
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
![Page 13: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/13.jpg)
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
![Page 14: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/14.jpg)
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;}
}
![Page 15: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/15.jpg)
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;
}
![Page 16: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/16.jpg)
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
![Page 17: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/17.jpg)
inJava
“Can’tIstayalittlelonger?I’msohappyhere.”
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �17
![Page 18: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/18.jpg)
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �18
The War of Programming Languages
![Page 19: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/19.jpg)
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
![Page 20: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/20.jpg)
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �20
… or Polyglot!
![Page 21: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/21.jpg)
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 ———>
![Page 22: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/22.jpg)
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
![Page 23: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/23.jpg)
“Nowisyourchancetoescape!” JVM
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �23
![Page 24: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/24.jpg)
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �24
standalone
![Page 25: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/25.jpg)
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
![Page 26: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/26.jpg)
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 ...;
![Page 27: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/27.jpg)
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 ...;
![Page 28: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/28.jpg)
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
and Its Ecosystem
�28
HotSpot VM Graal
Truffle Languages
Truffle Framework JVM Languages
Clojure
![Page 29: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/29.jpg)
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
![Page 30: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/30.jpg)
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. |
and Its Ecosystem
�30
Truffle Languages
Truffle Framework
Substrate VM
JVM Languages
Standalone
![Page 31: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/31.jpg)
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
![Page 32: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/32.jpg)
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
![Page 33: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/33.jpg)
“Takeiteasyandavoidexcitement.”
Copyright © 2019, Oracle and/or its affiliates. All rights reserved. | �33
![Page 34: : Run Programs Faster Anywher1. 3. e · Java Application JDK Substrate VM Application running without dependency on JDK and without Java class loading Reachable methods, fields, and](https://reader034.vdocuments.mx/reader034/viewer/2022043011/5fa6e8a881ff4b00810eadec/html5/thumbnails/34.jpg)