Abstract
Ruby is a dynamically typed programming language with a large breadth of features which has grown in popularity with the rise of the modern web, and remains at the core of the implementation of many widely-used websites.
CRuby, the default implementation of the language, features a JIT compiler known as MJIT, but developers often do not enable it in production environments, because it does not always yield performance improvements on real-world software. Attempts to independently reimplement the Ruby language, such as JRuby and TruffleRuby have shown impressive performance results on benchmarks, but often lag behind CRuby when it comes to supporting new additions to the language, which limits their adoption.
We introduce YJIT, a new JIT compiler built inside CRuby based on a Lazy Basic Block Versioning (LBBV) architecture. We show that while our compiler does not match the peak performance of TruffleRuby, it offers near-100% compatibility with existing Ruby code, impressively fast warmup, and speedups from 15% to 19% on sizeable benchmarks based on real-world software.
Formats available
You can view the full content in the following formats:
Supplementary Material
Updated talk for VMIL. Max talk slot duration is 20 minutes.
- Download
- 33.70 MB
References
[1]
Davide Ancona, Massimo Ancona, Antonio Cuni, and Nicholas D. Matsakis. 2007. RPython: A Step towards Reconciling Dynamically and Statically Typed OO Languages. In Proceedings of the 2007 Symposium on Dynamic Languages (DLS ’07). Association for Computing Machinery, New York, NY, USA. 53–64. isbn:9781595938688 https://doi.org/10.1145/1297081.1297091
[2]
Carl Friedrich Bolz, Antonio Cuni, Maciej Fijał kowski, Michael Leuschel, Samuele Pedroni, and Armin Rigo. 2011. Runtime Feedback in a Meta-Tracing JIT for Efficient Dynamic Languages. In Proceedings of the 6th Workshop on Implementation, Compilation, Optimization of Object-Oriented Languages, Programs and Systems (ICOOOLPS ’11). Association for Computing Machinery, New York, NY, USA. Article 9, 8 pages. isbn:9781450308946 https://doi.org/10.1145/2069172.2069181
[3]
Carl Friedrich Bolz, Antonio Cuni, Maciej Fijalkowski, and Armin Rigo. 2009. Tracing the Meta-Level: PyPy’s Tracing JIT Compiler. In Proceedings of the 4th Workshop on the Implementation, Compilation, Optimization of Object-Oriented Languages and Programming Systems (ICOOOLPS ’09). Association for Computing Machinery, New York, NY, USA. 18–25. isbn:9781605585413 https://doi.org/10.1145/1565824.1565827
[4]
Stefan Brunthaler. 2010. Efficient Interpretation Using Quickening. SIGPLAN Not., 45, 12 (2010), Oct., 1–14. issn:0362-1340 https://doi.org/10.1145/1899661.1869633
[5]
C. Chambers, D. Ungar, and E. Lee. 1989. An Efficient Implementation of SELF a Dynamically-Typed Object-Oriented Language Based on Prototypes. In Conference Proceedings on Object-Oriented Programming Systems, Languages and Applications (OOPSLA ’89). Association for Computing Machinery, New York, NY, USA. 49–70. isbn:0897913337 https://doi.org/10.1145/74877.74884
[6]
Maxime Chevalier-Boisvert and Marc Feeley. 2015. Simple and Effective Type Check Removal through Lazy Basic Block Versioning. In 29th European Conference on Object-Oriented Programming, ECOOP 2015, July 5-10, 2015, Prague, Czech Republic, John Tang Boyland (Ed.) (LIPIcs, Vol. 37). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 101–123. https://doi.org/10.4230/LIPIcs.ECOOP.2015.101
[7]
Maxime Chevalier-Boisvert and Marc Feeley. 2016. Interprocedural Type Specialization of JavaScript Programs Without Type Analysis. In 30th European Conference on Object-Oriented Programming, ECOOP 2016, July 18-22, 2016, Rome, Italy, Shriram Krishnamurthi and Benjamin S. Lerner (Eds.) (LIPIcs, Vol. 56). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 7:1–7:24. https://doi.org/10.4230/LIPIcs.ECOOP.2016.7
[8]
Igor Costa, Péricles Alves, Henrique Nazaré Santos, and Fernando Magno Quintão Pereira. 2013. Just-in-time value specialization. In Proceedings of the 2013 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). 1–11. https://doi.org/10.1109/CGO.2013.6495006
[9]
Benoit Daloze, Stefan Marr, Daniele Bonetta, and Hanspeter Mössenböck. 2016. Efficient and Thread-Safe Objects for Dynamically-Typed Languages. In Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA 2016). Association for Computing Machinery, New York, NY, USA. 642–659. isbn:9781450344449 https://doi.org/10.1145/2983990.2984001
[10]
L. Peter Deutsch and Allan M. Schiffman. 1984. Efficient Implementation of the Smalltalk-80 System. In Proceedings of the 11th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages (POPL ’84). Association for Computing Machinery, New York, NY, USA. 297–302. isbn:0897911253 https://doi.org/10.1145/800017.800542
[11]
Kevin Menard, Chris Seaton, and Benoit Daloze. 2018. Specializing Ropes for Ruby. In Proceedings of the 15th International Conference on Managed Languages & Runtimes (ManLang ’18). Association for Computing Machinery, New York, NY, USA. Article 10, 7 pages. isbn:9781450364249 https://doi.org/10.1145/3237009.3237026
[12]
Gregor Richards, Ellen Arteca, and Alexi Turcotte. 2017. The VM already knew that: leveraging compile-time knowledge to optimize gradual typing. Proc. ACM Program. Lang., 1, OOPSLA (2017), 55:1–55:27. https://doi.org/10.1145/3133879
[13]
Armin Rigo. 2004. Representation-Based Just-in-Time Specialization and the Psyco Prototype for Python. In Proceedings of the 2004 ACM SIGPLAN Symposium on Partial Evaluation and Semantics-Based Program Manipulation (PEPM ’04). Association for Computing Machinery, New York, NY, USA. 15–26. isbn:1581138350 https://doi.org/10.1145/1014007.1014010
[14]
Baptiste Saleil and Marc Feeley. 2017. Interprocedural Specialization of Higher-Order Dynamic Languages Without Static Analysis. In 31st European Conference on Object-Oriented Programming, ECOOP 2017, June 19-23, 2017, Barcelona, Spain, Peter Müller (Ed.) (LIPIcs, Vol. 74). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 23:1–23:23. https://doi.org/10.4230/LIPIcs.ECOOP.2017.23
[15]
Baptiste Saleil and Marc Feeley. 2018. Building JIT compilers for dynamic languages with low development effort. In Proceedings of the 10th ACM SIGPLAN International Workshop on Virtual Machines and Intermediate Languages, VMIL@SPLASH 2018, Boston, MA, USA, November 4, 2018, Stephen Kell and Stefan Marr (Eds.). ACM, 36–46. https://doi.org/10.1145/3281287.3281294
[16]
Aibek Sarimbekov, Andrej Podzimek, Lubomir Bulej, Yudi Zheng, Nathan Ricci, and Walter Binder. 2013. Characteristics of Dynamic JVM Languages. In Proceedings of the 7th ACM Workshop on Virtual Machines and Intermediate Languages (VMIL ’13). Association for Computing Machinery, New York, NY, USA. 11–20. isbn:9781450326018 https://doi.org/10.1145/2542142.2542144
[17]
Koichi Sasada. 2005. YARV: Yet Another RubyVM: Innovating the Ruby Interpreter. In Companion to the 20th Annual ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA ’05). Association for Computing Machinery, New York, NY, USA. 158–159. isbn:1595931937 https://doi.org/10.1145/1094855.1094912
[18]
Chris Seaton. 2015. Specialising Dynamic Techniques for Implementing the Ruby Programming Language. Ph.D. Dissertation. University of Manchester.
[19]
Pat. Shaughnessy. 2013 - 2014. Ruby under a microscope : An illustrated guide to ruby internals (1st edition ed.). No Starch Press, San Francisco. isbn:1-59327-561-7
[20]
Andreas Wöß, Christian Wirth, Daniele Bonetta, Chris Seaton, Christian Humer, and Hanspeter Mössenböck. 2014. An Object Storage Model for the Truffle Language Implementation Framework. In Proceedings of the 2014 International Conference on Principles and Practices of Programming on the Java Platform: Virtual Machines, Languages, and Tools (PPPJ ’14). Association for Computing Machinery, New York, NY, USA. 133–144. isbn:9781450329262 https://doi.org/10.1145/2647508.2647517
[21]
Thomas Würthinger, Christian Wimmer, Andreas Wöß, Lukas Stadler, Gilles Duboscq, Christian Humer, Gregor Richards, Doug Simon, and Mario Wolczko. 2013. One VM to Rule Them All. In Proceedings of the 2013 ACM International Symposium on New Ideas, New Paradigms, and Reflections on Programming & Software (Onward! 2013). Association for Computing Machinery, New York, NY, USA. 187–204. isbn:9781450324724 https://doi.org/10.1145/2509578.2509581
[22]
Thomas Würthinger, Andreas Wöß, Lukas Stadler, Gilles Duboscq, Doug Simon, and Christian Wimmer. 2012. Self-Optimizing AST Interpreters. In Proceedings of the 8th Symposium on Dynamic Languages (DLS ’12). Association for Computing Machinery, New York, NY, USA. 73–82. isbn:9781450315647 https://doi.org/10.1145/2384577.2384587
[23]
Shijie Xu, David Bremner, and Daniel Heidinga. 2017. Fusing Method Handle Graphs for Efficient Dynamic JVM Language Implementations. In Proceedings of the 9th ACM SIGPLAN International Workshop on Virtual Machines and Intermediate Languages (VMIL 2017). Association for Computing Machinery, New York, NY, USA. 18–27. isbn:9781450355193 https://doi.org/10.1145/3141871.3141874