Specialising dynamic techniques for implementing the Ruby programming language

Specialising dynamic techniques for implementing the Ruby programming language
复制标题

专门用于实现 Ruby 编程语言的动态技术

DOI:
--
复制
发表时间:
2015
期刊:
影响因子:
--
通讯作者:
Chris Seaton
Chris Seaton
中科院分区:
--
文献类型:
--
作者:
Chris Seaton

文献摘要

参考文献

被引文献

相似文献

Ruby编程语言是动态类型的,对所有运算符、方法调用和许多控制结构使用动态和后期绑定分派,并提供广泛的元编程和内省工具功能。与其他语言不同,这些功能在Ruby中是不可避免的,Ruby生态系统的关键部分广泛使用它们,即使是内部循环操作。这使得Ruby的高性能实现成为问题。现有的实现要么不尝试动态优化Ruby程序,或者在优化包含这些特性的Ruby程序方面取得相对有限的成功。社区解决现有Ruby实现的局限性的一种方法是用C语言编写扩展模块,编程语言。这些都是静态编译的,然后动态链接到Ruby实现中。与等价的Ruby相比,这种C代码对于计算密集型代码通常更有效。然而,这些C扩展提供的接口是由非优化Ruby的参考实现。想要通过使用不同的内部表示来优化的实现必须进行大量的复制以提供相同的接口。这然后限制了C扩展在这些实现中的性能。这使得Ruby处于困难的境地,不仅难以有效地实现语言,而且以前解决这个问题的方法,C扩展,这篇论文描述了一个Ruby编程语言的实现,它包含了Ruby语言,并专门针对Ruby进行了优化,因为它用于它提供了Ruby动态特性的高性能实现,同时提供了一个高性能的C扩展实现。该实现提供了与现有Ruby实现的高度兼容性,并且不限制可用的功能以实现高性能。本文中描述的所有技术的共同点是专业化的概念。传统的方法采用优化动态语言(如Ruby)的方法是在程序运行时对其进行分析。分析的反馈可以用来针对程序实际经历的数据和控制流进行专门化。本文通过专门化超出正常数据和控制流的条件来扩展和推进这一思想。调用方法的程序,或者通过动态名称而不是文字语法来查找变量或常量,可以通过一般化内联高速缓存来专门用于动态名称。C扩展被解释和动态优化而不是静态编译,并且C代码编程所针对的接口被提供为底层实现之上的抽象,其然后可以独立地专门化。在本论文中开发的技术对来自真实的的合成基准和内核的性能都有显著的影响。世界上的Ruby程序。已经开发的Ruby的实现与下一个最好的实现相比在性能上实现了数量级或更好的提高。在许多情况下,这些技术是“零开销”的,因为当使用Ruby的最动态特性时,生成的机器代码完全相同,如当仅使用静态特征时。
The Ruby programming language is dynamically typed, uses dynamic and late bound dispatch for all operators, method calls and many control structures, and provides extensive metaprogramming and introspective tooling functionality.Unlike other languages where these features are available, in Ruby their use is not avoided and key parts of the Ruby ecosystem use them extensively, even for inner-loop operations.This makes a high-performance implementation of Ruby problematic.Existing implementations either do not attempt to dynamically optimise Ruby programs, or achieve relatively limited success in optimising Ruby programs containing these features.One way that the community has worked around the limitations of existing Ruby implementations is to write extension modules in the C programming language.These are statically compiled and then dynamically linked into the Ruby implementation.Compared to equivalent Ruby, this C code is often more efficient for computationally intensive code.However the interface that these C extensions provides is defined by the non-optimising reference implementation of Ruby.Implementations which want to optimise by using different internal representations must do extensive copying to provide the same interface.This then limits the performance of the C extensions in those implementations.This leaves Ruby in the difficult position where it is not only difficult to implement the language efficiently, but the previous workaround for that problem, C extensions, also limits efforts to improve performance.This thesis describes an implementation of the Ruby programming language which embraces the Ruby language and optimises specifically for Ruby as it is used in practice.It provides a high performance implementation of Ruby's dynamic features, at the same time as providing a high performance implementation of C extensions.The implementation provides a high level of compatibility with existing Ruby implementations and does not limit the available features in order to achieve high performance.Common to all the techniques that are described in this thesis is the concept of specialisation.The conventional approach taken to optimise a dynamic language such as Ruby is to profile the program as it runs.Feedback from the profiling can then be used to specialise the program for the data and control flow it is actually experiencing.This thesis extends and advances that idea by specialising for conditions beyond normal data and control flow.Programs that call a method, or lookup a variable or constant by dynamic name rather than literal syntax can be specialised for the dynamic name by generalising inline caches.Debugging and introspective tooling is implemented by specialising the code for debug conditions such as the presence of a breakpoint or an attached tracing tool.C extensions are interpreted and dynamically optimised rather than being statically compiled, and the interface which the C code is programmed against is provided as an abstraction over the underlying implementation which can then independently specialise.The techniques developed in this thesis have a significant impact on performance of both synthetic benchmarks and kernels from real-world Ruby programs.The implementation of Ruby which has been developed achieves an order of magnitude or better increase in performance compared to the next-best implementation.In many cases the techniques are `zero-overhead', in that the generated machine code is exactly the same for when the most dynamic features of Ruby are used, as when only static features are used.
DOI: 10.1145/2754169.2754187
发表时间: 2015-06
期刊: Proceedings of the 2015 International Symposium on Memory Management
影响因子: --
作者:
Yi Lin;Kunshan Wang;S. Blackburn;Antony Hosking;Michael Norrish
通讯作者: Yi Lin;Kunshan Wang;S. Blackburn;Antony Hosking;Michael Norrish