论文标题

为类型反馈采样优化的代码

Sampling Optimized Code for Type Feedback

论文作者

Flückiger, Olivier, Wälchli, Andreas, Krynski, Sebastián, Vitek, Jan

论文摘要

为了有效地执行动态键入的语言,许多语言实现采用了两层体系结构。第一个层次是低延迟启动时间,并收集动态配置文件,例如变量的动态类型。第二层使用优化编译器提供高通量,该编译器将代码专门用于记录的类型信息。如果程序行为更改为以前未看到类型的观点,则该专用代码在专业代码中变得无效,它将被取代,并且控件将转移回第一个将开始专业化的执行引擎。但是,如果程序行为变得更具体,例如,如果多态变量变成单态,则没有任何变化。一旦程序运行优化代码,就无法注意到错过了优化的机会。 我们建议采用基于抽样的探查器来监视本机代码,而无需任何仪器。缺乏仪器意味着当探查者不活跃时,不会产生开销。我们提出实现的目的是在“及时”的上下文中,优化了R语言的编译器。基于采样的配置文件,我们能够检测到产生的本机代码何时专门用于陈旧的反馈,并将其重新编译为更特定类型的代码。我们表明,在大多数情况下,采样在少数情况下增加了不到3%的开销,并且在少数情况下增加了9%,并且可靠地检测到毫秒内的陈旧反馈。

To efficiently execute dynamically typed languages, many language implementations have adopted a two-tier architecture. The first tier aims for low-latency startup times and collects dynamic profiles, such as the dynamic types of variables. The second tier provides high-throughput using an optimizing compiler that specializes code to the recorded type information. If the program behavior changes to the point that not previously seen types occur in specialized code, that specialized code becomes invalid, it is deoptimized, and control is transferred back to the first tier execution engine which will start specializing anew. However, if the program behavior becomes more specific, for instance, if a polymorphic variable becomes monomorphic, nothing changes. Once the program is running optimized code, there are no means to notice that an opportunity for optimization has been missed. We propose to employ a sampling-based profiler to monitor native code without any instrumentation. The absence of instrumentation means that when the profiler is not active, no overhead is incurred. We present an implementation is in the context of the Ř just-in-time, optimizing compiler for the R language. Based on the sampled profiles, we are able to detect when the native code produced by Ř is specialized for stale type feedback and recompile it to more type-specific code. We show that sampling adds an overhead of less than 3% in most cases and up to 9% in few cases and that it reliably detects stale type feedback within milliseconds.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源