| Op?mizing Ruby with TruffleRuby The Ruby Logo is Copyright (c) 2006, Yukihiro Matsumoto. It is licensed under the terms of the Crea?ve Commons APribu?on-‐ShareAlike 2.5 agreement. Slides from Chris Seaton Oracle Labs @ChrisGSeaton Benoit Daloze @eregontp 15 March 2017 Linz Ruby User Group
| Safe Harbor Statement The following is intended to provide some insight into a line of research in Oracle Labs. It is intended for informa?on purposes only, and may not be incorporated into any contract. It is not a commitment to deliver any material, code, or func?onality, and should not be relied upon in making purchasing decisions. Oracle reserves the right to alter its development plans and prac?ces at any ?me, and the development, release, and ?ming of any features or func?onality described in connec?on with any Oracle product or service remains at the sole discre?on of Oracle. Any views expressed in this presenta?on are my own and do not necessarily reflect the views of Oracle. 2
| Who am I ? • Benoit Daloze • PhD student at Johannes Kepler University • Research with TruffleRuby on concurrency • MRI and JRuby commiPer • Maintainer of the Ruby Spec Suite (ruby/spec) 3 TwiPer: @eregontp GitHub: @eregon
| The JRuby logo is copyright (c) Tony Price 2011, licensed under the terms of Crea?ve Commons APribu?on-‐NoDerivs 3.0 Unported (CC BY-‐ND 3.0) JRuby JITs by emihng JVM bytecode VM in Java Core library mostly in Java
| The Rubinius logo is copyright 2011 Shane Becker, licensed under the terms of Crea?ve Commons APribu?on-‐NoDeriva?ves 4.0 Interna?onal — CC BY-‐ND 4.0 Rubinius JITs by emihng LLVM bitcode VM in C++ Core library mostly in Ruby
| The Rubinius logo is copyright 2011 Shane Becker, licensed under the terms of Crea?ve Commons APribu?on-‐NoDeriva?ves 4.0 Interna?onal — CC BY-‐ND 4.0 Rubinius JITs by emihng LLVM bitcode VM in C++ Core library mostly in Ruby
| U U U U U I I I G G I I I G G Node Rewriting for Profiling Feedback AST Interpreter Rewritten Nodes AST Interpreter Uninitialized Nodes Compilation using Partial Evaluation Compiled Code 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. Compiling the AST to machine code
| 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 D G G D I D G G Node Rewriting to Update Profiling Feedback Recompilation using Partial Evaluation Deop?miza?on and recompila?on
| So then why can’t we run real applica?ons yet? • C extensions are s?ll a work in progress – Almost no database drivers – No openssl – No nokogiri – Prevents us running almost everything unfortunately • The specs don’t have perfect coverage 79
| Ongoing Research • Running C extension with Sulong (Truffle+LLVM) • ObjectSpace: stop the world and walk the frames • Represen?ng String as Ropes • Efficient parallelism: • Thread-‐Safe Objects for Dynamic Languages • Thread-‐Safe and Scalable Ruby collec?ons
| Conclusions Simple VM ideas can solve the major problems of making Ruby fast We don’t need to tell Ruby programmers to avoid language features to get performance
| 86 Acknowledgements Oracle Danilo Ansaloni Stefan Anzinger Cosmin Basca Daniele BonePa MaPhias Brantner Petr Chalupa Jürgen Christ Laurent Daynès Gilles Duboscq Mar?n Entlicher Brandon Fish Bas?an Hossbach Chris?an Humer Mick Jordan Vojin Jovanovic Peter Kessler David Leopoldseder Duncan MacGregor Kevin Menard Jakub Podlešák Aleksandar Prokopec Tom Rodriguez Oracle (con0nued) 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 Chris?an Wimmer Chris?an Wirth Paul Wögerer Mario Wolczko Andreas Wöß Thomas Würthinger JKU Linz Prof. Hanspeter Mössenböck Benoit Daloze Josef Eisl Thomas Feich?nger MaPhias Grimmer Chris?an Häubl Josef Haider Chris?an 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 KoPhaus 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 Kun… Volker Lan?ng Gero Leinemann Julian LePner 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