paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Type-Based Gradual Typing Performance Optimization

基于类型的渐进类型(gradual typing)性能优化
POPL 8(POPL)2024匹配度 2/10 · 论文属于渐进类型系统的性能优化与编译实现,虽与程序语言/类型系统相关,但未涉及用户核心关注的 ML/Agent 静态分析、LLM 辅助分析/验证、浮点程序分析或贝叶斯程序分析。引用 2 inbox
John Peter Campora, Mohammad Wahiduzzaman Khan, Sheng Chen
crossref: 2026-09-10

AI 速览

一句话:提出判别式类型化:乐观推断函数类型并生成优化/未优化双版本,在保持安全性的同时大幅降低渐进类型开销。

渐进类型允许程序员自由混用静态与动态类型,为保证类型可靠性,运行期检查被插入到类型化与非类型化代码的边界上,但在混用密集的程序中会带来显著的运行期开销。本文提出判别式类型化(discriminative typing),在不修改语言底层实现的前提下缓解该开销:它乐观地为函数推断类型,并基于该类型生成一个优化版本;同时依据源码中给出的注解保留一个未优化版本以保证安全。程序随后被翻译为尽量多地调用优化版本、同时保持原有行为的形态。作者在 Reticulated Python 中实现了该技术并与 guarded Reticulated Python 对比:95% 的测试程序性能得到提升,其中 56% 以上获得超过 4 倍加速;与先前的优化方法相比,93% 的程序性能提升,30% 的程序获得 4 至 25 倍加速。此外,判别式类型化显著降低了多种混合类型配置下的渐进类型开销。作者还在 Grift 中实现并评估了该技术,结果表明其性能同样获得显著改善。

问题
渐进类型为保证类型可靠性而在类型化与非类型化代码边界插入运行期检查,导致混用静态与动态类型的程序出现严重性能开销。
方法
提出判别式类型化:乐观推断函数类型并据此实现优化版本,同时保留基于注解的未优化版本以保安全性,再通过程序翻译尽可能多地调用优化版本。
评估
在 Reticulated Python 与 Grift 中实现,并与 guarded Reticulated Python 及先前的优化方法在大量混合类型配置的程序上比较运行性能。
原文摘要(Abstract)

Gradual typing has emerged as a popular design point in programming languages, attracting significant interests from both academia and industry. Programmers in gradually typed languages are free to utilize static and dynamic typing as needed. To make such languages sound, runtime checks mediate the boundary of typed and untyped code. Unfortunately, such checks can incur significant runtime overhead on programs that heavily mix static and dynamic typing. To combat this overhead without necessitating changes to the underlying implementations of languages, we present discriminative typing . Discriminative typing works by optimistically inferring types for functions and implementing an optimized version of the function based on this type. To preserve safety it also implements an un-optimized version of the function based purely on the provided annotations. With two versions of each function in hand, discriminative typing translates programs so that the optimized functions are called as frequently as possible while also preserving program behaviors. We have implemented discriminative typing in Reticulated Python and have evaluated its performance compared to guarded Reticulated Python. Our results show that discriminative typing improves the performance across 95% of tested programs, when compared to Reticulated, and achieves more than 4× speedup in more than 56% of these programs. We also compare its performance against a previous optimization approach and find that discriminative typing improved performance across 93% of tested programs, with 30% of these programs receiving speedups between 4 to 25 times. Finally, our evaluation shows that discriminative typing remarkably reduces the overhead of gradual typing on many mixed type configurations of programs. In addition, we have implemented discriminative typing in Grift and evaluated its performance. Our evaluation demonstrations that DT significantly improves performance of Grift.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot2612,
  title = {Type-Based Gradual Typing Performance Optimization},
  author = {John Peter Campora and Mohammad Wahiduzzaman Khan and Sheng Chen},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {8},
  number = {POPL},
  year = {2024},
  doi = {10.1145/3632931}
}