一句话:通过数万性能调试场景实验比较17种剖析器引导策略,发现用深度类型消除昂贵边界最有效。
健全的迁移类型化旨在安全顺畅地将无类型代码重构为有类型代码,但运行时检查会带来高昂成本,常常导致性能回退。由于迁移类型格的规模随组件数指数增长,开发者很难判断应为哪些组件添加类型。本文遵循理性程序员方法,将现成性能剖析器的输出转化为可执行的迁移下一步,并设计了17种策略,在数万个性能调试场景中进行实验。结果表明,最有效的策略是使用深度类型来消除类型化与无类型组件之间代价最高的边界;若允许过程中出现两次性能退化,该策略在超过50%的场景中成功。
Sound migratory typing envisions a safe and smooth refactoring of untyped code bases to typed ones. However, the cost of enforcing safety with run-time checks is often prohibitively high, thus performance regressions are a likely occurrence. Additional types can often recover performance, but choosing the right components to type is difficult because of the exponential size of the migratory typing lattice. In principal though, migration could be guided by off-the-shelf profiling tools. To examine this hypothesis, this paper follows the rational programmer method and reports on the results of an experiment on tens of thousands of performance-debugging scenarios via seventeen strategies for turning profiler output into an actionable next step. The most effective strategy is the use of deep types to eliminate the most costly boundaries between typed and untyped components; this strategy succeeds in more than 50% of scenarios if two performance degradations are tolerable along the way.
@article{paperbot1847,
title = {How Profilers Can Help Navigate Type Migration},
author = {Ben Greenman and Matthias Felleisen and Christos Dimoulas},
journal = {Proceedings of the ACM on Programming Languages},
volume = {7},
number = {OOPSLA2},
year = {2023},
doi = {10.1145/3622817}
}