arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2603.05649cs.PL
收藏

渐进类型中类型注解高效选择以提升性能

Efficient Selection of Type Annotations for Performance Improvement in Gradual Typing

The University of Tokyo(东京大学)

Senxi Li, Feng Dai, Tetsuro Yamazaki, Shigeru Chiba

AI总结:

本文提出了一种通过类型推断选择类型注解子集的方法,以提高渐进类型程序的执行性能,实验表明其在Reticulated Python中有效。

摘要:

渐进类型作为一种将静态类型和动态类型整合在同一语言中的设计选择,已受到广泛欢迎。几种实际语言已采用渐进类型,为程序员提供灵活的注解程序需求。然而,部分类型程序存在意外性能下降的关键挑战。简单地添加更多类型注解可能会显著降低执行速度。先前研究已探讨了选择性添加类型注解以提高性能的策略。然而,这些方法在编译时间上受到限制,阻碍了实际应用。本文提出了一种新的技术,通过类型推断选择类型注解的子集以提高渐进类型程序的执行性能。该方法的优势是通过轻量级、摊还的方法缩短编译时间。它沿着数据流选择类型注解,预计可以避免由于值反复跨过无类型和类型代码边界而产生的昂贵运行时转换。我们展示了我们提案的适用性,并进行了实验以验证其在Reticulated Python上提高执行时间的有效性。我们的实现支持Python子集,以选择由实现的外部类型推断引擎推导出的类型注解。实验结果表明,我们的提案在基准程序中优于使用所有由类型推断推导出的类型注解的朴素策略。与现有方法相比,该提案在执行速度上具有可比性,并在保持推导和选择类型注解的编译时间更稳定的方面具有优势。我们的结果表明,该技术在Reticulated Python中是实用的,可用于缓解渐进类型程序的性能瓶颈。

英文摘要:

Gradual typing has gained popularity as a design choice for integrating static and dynamic typing within a single language. Several practical languages have adopted gradual typing to offer programmers the flexibility to annotate their programs as needed. Meanwhile there is a key challenge of unexpected performance degradation in partially typed programs. The execution speed may significantly decrease when simply adding more type annotations. Prior studies have investigated strategies of selectively adding type annotations for better performance. However, they are restricted in substantial compilation time, which impedes the practical usage. This paper presents a new technique to select a subset of type annotations derived by type inference for improving the execution performance of gradually typed programs. The advantage of the proposal is shorter compilation time by employing a lightweight, amortized approach. It selects type annotations along the data flows, which is expected to avoid expensive runtime casts caused by a value repeatedly crossing the boundaries between untyped and typed code. We demonstrate the applicability of our proposal, and conduct experiments to validate its effectiveness of improving the execution time on Reticulated Python. Our implementation supports a Python subset to select type annotations derived by an implemented, external type inference engine. Experiment results show that our proposal outperforms a naive strategy of using all type annotations derived by type inference among the benchmark programs. In comparison with an existing approach, the proposal achieves comparable execution speed and shows advantage of maintaining a more stable compilation time of deriving and selecting type annotations. Our results empirically indicate that the proposed technique is practical within Reticulated Python for mitigating the performance bottleneck of gradually typed programs.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑