Share
Embed
Transcript
102 slides
-
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Turning the JVM into a Polyglot VM with Graal Chris Seaton Research Manager Oracle Labs April 2017 -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Safe Harbor Statement The following is intended to provide some insight into a line of research in Oracle Labs. It is intended for information 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. Oracle reserves the right to alter its development plans and practices at any time, and the development, release, and timing of any features or functionality described in connection with any Oracle product or service remains at the sole discretion of Oracle. Any views expressed in this presentation are my own and do not necessarily reflect the views of Oracle. -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Programming languages -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 8 Computer Language Benchmarks Game -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 9 Goal: Computer Language Benchmarks Game -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 10 Prototype a new language Parser and language work to build syntax tree (AST), AST Interpreter Write a “real” VM In C/C++, still using AST interpreter, spend a lot of time implementing runtime system, GC, … People start using it Define a bytecode format and write bytecode interpreter People complain about performance Write a JIT compiler Improve the garbage collector Performance is still bad Current situation How it should be -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 11 Prototype a new language Parser and language work to build syntax tree (AST), AST Interpreter Write a “real” VM In C/C++, still using AST interpreter, spend a lot of time implementing runtime system, GC, … People start using it Define a bytecode format and write bytecode interpreter People complain about performance Write a JIT compiler Improve the garbage collector Performance is still bad Prototype a new language in Java Parser and language work to build syntax tree (AST) Execute using AST interpreter People start using it And it is already fast Current situation How it should be -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| The GraalVM concept -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 13 The Ruby Logo is Copyright (c) 2006, Yukihiro Matsumoto. It is licensed under the terms of the Creative Commons Attribution-ShareAlike 2.5 agreement JS Logo Copyright (c) 2011 Christopher Williams <[email protected]>, MIT licence You can distribute the R logo under the terms of the Creative Commons Attribution-ShareAlike 4.0 International license (CC-BY-SA 4.0) or (at your option) the GNU General Public License version 2 (GPL-2). -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 14 VM VM VM VM Impl Impl Impl Impl -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 15 VM VM VM VM Impl Impl Impl Impl -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 16 VM Impl Impl Impl Impl -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 17 VM Impl Impl Impl Impl -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 18 VM Impl Impl Impl Impl -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| How we do polyglot in GraalVM -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Ruby JavaScript -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Ruby JavaScript -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Ruby JavaScript -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Warms up and then reports iterations per second Random inputs stop the whole thing being totally optimised away -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| clamp in Pure Ruby 0 1000000 2000000 3000000 4000000 5000000 6000000 7000000 8000000 9000000 10000000 GraalVM JRuby+invokedynamic Ruby Operations Per Second -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| clamp in Pure Ruby 0 1000000 2000000 3000000 4000000 5000000 6000000 7000000 8000000 9000000 10000000 GraalVM JRuby+invokedynamic Ruby Operations Per Second This is what GraalVM is giving you for Ruby before we even start talking about JavaScript -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Not only have we rewritten in JavaScript, but the JavaScript code is simpler than the Ruby -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| clamp in Ruby and JavaScript with V8 0 50000 100000 150000 200000 250000 300000 350000 Ruby (just Ruby) Ruby (Ruby + JS with V8) Operations Per Second -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| clamp in Ruby and JavaScript with JRuby and Rhino 0 100000 200000 300000 400000 500000 600000 JRuby+indy (just Ruby) JRuby+indy (Ruby + JS with Rhino) Operations Per Second -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| clamp in Ruby and JavaScript with JRuby and Nashorn 0 100000 200000 300000 400000 500000 600000 JRuby+indy (just Ruby) JRuby+indy (Ruby + JS with Rhino) JRuby+indy (Ruby + JS with Nashorn) Operations Per Second -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| clamp in Ruby and JavaScript with GraalVM 0 1000000 2000000 3000000 4000000 5000000 6000000 7000000 8000000 9000000 10000000 GraalVM (just Ruby) GraalVM (Ruby + JS) JRuby+invokedynamic Ruby Operations Per Second -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| clamp in all configurations 0 1000000 2000000 3000000 4000000 5000000 6000000 7000000 8000000 9000000 10000000 GraalVM (just Ruby) GraalVM (Ruby + JS) JRuby+indy (just Ruby) JRuby+indy (Ruby + JS with Rhino) JRuby+indy (Ruby + JS with Nashorn) Ruby (just Ruby) Ruby (Ruby + JS with V8) Operations Per Second -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| clamp in all configurations 1 10 100 1000 10000 100000 1000000 10000000 GraalVM (just Ruby) GraalVM (Ruby + JS) JRuby+indy (just Ruby) JRuby+indy (Ruby + JS with Rhino) JRuby+indy (Ruby + JS with Nashorn) Ruby (just Ruby) Ruby (Ruby + JS with V8) Operations Per Second -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| How Graal achieves this -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Conventional JVM implementations of languages work by emitting JVM bytecode – the same thing that the Java compiler does -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Hotspot Graal JIT -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Hotspot Graal Truffle -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Slightly confusing terminology… • Graal is a new JIT compiler for the JVM • Graal VM is the JVM, with Graal, Truffle, and our languages bundled in it • Truffle uses Graal on your behalf -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 56 Guest Language JVM Bytecode -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 57 Guest Language Compiler internal data structures, optimisation passes, machine code, … Graal -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 58 Guest Language Graal Truffle language interpreter -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| The very basics of Truffle and Graal -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| x + y * z + x * y z load_local x load_local y load_local z call * call + pushq %rbp movq %rsp, %rbp movq %rdi, -8(%rbp) movq %rsi, -16(%rbp) movq %rdx, -24(%rbp) movq -16(%rbp), %rax movl %eax, %edx movq -24(%rbp), %rax imull %edx, %eax movq -8(%rbp), %rdx addl %edx, %eax popq %rbp ret -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| x + y * z + x * y z load_local x load_local y load_local z call * call + pushq %rbp movq %rsp, %rbp movq %rdi, -8(%rbp) movq %rsi, -16(%rbp) movq %rdx, -24(%rbp) movq -16(%rbp), %rax movl %eax, %edx movq -24(%rbp), %rax imull %edx, %eax movq -8(%rbp), %rdx addl %edx, %eax popq %rbp ret -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| x + y * z + x * y z load_local x load_local y load_local z call * call + pushq %rbp movq %rsp, %rbp movq %rdi, -8(%rbp) movq %rsi, -16(%rbp) movq %rdx, -24(%rbp) movq -16(%rbp), %rax movl %eax, %edx movq -24(%rbp), %rax imull %edx, %eax movq -8(%rbp), %rdx addl %edx, %eax popq %rbp ret -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| U U U U U Node Rewriting for Profiling Feedback AST Interpreter Uninitialized Nodes Node Transitions S U I D G Uninitialized Integer Generic Double String T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon, and M. Wolczko. One VM to rule them all. In Proceedings of Onward!, 2013. -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| U U U U U I I I G G Node Rewriting for Profiling Feedback AST Interpreter Rewritten Nodes AST Interpreter Uninitialized Nodes Node Transitions S U I D G Uninitialized Integer Generic Double String T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon, and M. Wolczko. One VM to rule them all. In Proceedings of Onward!, 2013. -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| I I I G G I I I G G Rewriting ng Feedback AST Interpreter Rewritten Nodes Compilation using Partial Evaluation Compiled Code I D Uninitialized Integer Generic Double T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon, and M. Wolczko. One VM to rule them all. In Proceedings of Onward!, 2013. -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 66 codon.com/compilers-for-free Presentation, by Tom Stuart, licensed under a Creative Commons Attribution ShareAlike 3.0 -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 20/04/2017 T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon, and M. Wolczko. One VM to rule them all. In Proceedings of Onward!, 2013. I I I G G I I I G G Deoptimization to AST Interpreter D I Node Rewriting to Update Profiling Feedback -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 20/04/2017 Oracle Confidential – Internal/Restricted/Highly Restricted T. Würthinger, C. Wimmer, A. Wöß, L. Stadler, G. Duboscq, C. Humer, G. Richards, D. Simon, and M. Wolczko. One VM to rule them all. In Proceedings of Onward!, 2013. I I G G D I D G G D I D G G Node Rewriting to Update Profiling Feedback Recompilation using Partial Evaluation -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 70 Frequently executed call -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| 72 Frequently executed call -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| How effective is this in the extreme? -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Looking at these loops here -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| What is this for? -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| • We’re not really suggesting that people routinely write alternate methods in different languages -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| • We’re not really suggesting that people routinely write alternate methods in different languages • More about removing the consideration of performance from the decision if you do want to combine languages -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| • Could make all library ecosystems available to all applications • May be useful for unifying a front-end and back-end • May be useful in handling legacy applications and incremental changes in implementation language -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| How to use GraalVM -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| GraalVM – everything in one package today • Includes: – JVM (RE or DK) – Java – JavaScript – Ruby – R – More in the future • Binary tarball release • Mac or Linux -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Java 9 – runs on an unmodified JVM Hotspot Graal Truffle JS others… R Java C++ -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Java 9 – runs on an unmodified JVM Hotspot Graal Truffle JS others… R Java C++ JVMCI (JVM Compiler Interface) -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Java 9 – runs on an unmodified JVM Hotspot Graal Truffle JS others… Ruby via OTN, Maven etc Java 9, JEP 243 -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| • Oracle Labs is building Graal VM to support polyglot programs and programmers • Extremely high performance for the languages on their own • Completely unprecedented high performance for language interoperability • Will work on an unmodified Java 9 JVM, or available as a bundle today • Still at the research stage, but moving towards being something more than that -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Where to find more information -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Search for ‘graal otn’ www.oracle.com/technetwork/oracle-labs/program-languages -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Search for ‘github graalvm’ github.com/graalvm -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| @chrisgseaton github.com/graalvm gitter.im/graalvm/graal-core Search ‘otn graalvm’ -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Acknowledgements Oracle Danilo Ansaloni Stefan Anzinger Cosmin Basca Daniele Bonetta Matthias Brantner Petr Chalupa Jürgen Christ Laurent Daynès Gilles Duboscq Martin Entlicher Brandon Fish Bastian Hossbach Christian Humer Mick Jordan Vojin Jovanovic Peter Kessler David Leopoldseder Kevin Menard Jakub Podlešák Aleksandar Prokopec Tom Rodriguez Oracle (continued) Roland Schatz Chris Seaton Doug Simon Štěpán Šindelář Zbyněk Šlajchrt Lukas Stadler Codrut Stancu Jan Štola Jaroslav Tulach Michael Van De Vanter Adam Welc Christian Wimmer Christian Wirth Paul Wögerer Mario Wolczko Andreas Wöß Thomas Würthinger JKU Linz Prof. Hanspeter Mössenböck Benoit Daloze Josef Eisl Thomas Feichtinger Matthias Grimmer Christian Häubl Josef Haider Christian Huber Stefan Marr Manuel Rigger Stefan Rumzucker Bernhard Urban University of Edinburgh Christophe Dubach Juan José Fumero Alfonso Ranjeet Singh Toomas Remmelg LaBRI Floréal Morandat University of California, Irvine Prof. Michael Franz Gulfem Savrun Yeniceri Wei Zhang Purdue University Prof. Jan Vitek Tomas Kalibera Petr Maj Lei Zhao T. U. Dortmund Prof. Peter Marwedel Helena Kotthaus Ingo Korb University of California, Davis Prof. Duncan Temple Lang Nicholas Ulle University of Lugano, Switzerland Prof. Walter Binder Sun Haiyang Yudi Zheng Oracle Interns Brian Belleville Miguel Garcia Shams Imam Alexey Karyakin Stephen Kell Andreas Kunft Volker Lanting Gero Leinemann Julian Lettner Joe Nash David Piorkowski Gregor Richards Robert Seilbeck Rifat Shariyar Alumni Erik Eckstein Michael Haupt Christos Kotselidis Hyunjin Lee David Leibs Chris Thalinger Till Westmann -
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| Safe Harbor Statement The preceding is intended to provide some insight into a line of research in Oracle Labs. It is intended for information 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. Oracle reserves the right to alter its development plans and practices at any time, and the development, release, and timing of any features or functionality described in connection with any Oracle product or service remains at the sole discretion of Oracle. Any views expressed in this presentation are my own and do not necessarily reflect the views of Oracle.