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.


翻译:渐进类型作为一种将静态类型与动态类型集成于单一语言的设计选择已获得广泛关注。多个实用语言采用渐进类型,为程序员提供了按需标注程序的灵活性。然而,部分类型化程序中存在的意外性能下降问题构成关键挑战。简单地增加类型标注可能导致执行速度显著降低。已有研究探讨了选择性添加类型标注以提升性能的策略,但这些方法存在编译时间过长的局限性,阻碍了实际应用。本文提出一种新技术,通过选择类型推断所生成类型标注的子集来改善渐进类型化程序的执行性能。该方案的优势在于采用轻量级摊销方法,从而缩短编译时间。该方法沿数据流路径选择类型标注,有望避免因值反复跨越无类型代码与类型化代码边界而产生的高开销运行时强制转换。我们论证了该方案的适用性,并通过实验验证其在Reticulated Python上改善执行时间的有效性。我们的实现支持Python子集,能够选择由已实现的外部类型推断引擎推导出的类型标注。实验结果表明,在基准测试程序中,本方案优于直接使用类型推断生成全部类型标注的朴素策略。与现有方法相比,本方案实现了相当的执行速度,并展现出在推导与选择类型标注过程中保持更稳定编译时间的优势。实验结果从实证角度表明,所提技术在Reticulated Python中具有实用性,能够有效缓解渐进类型化程序的性能瓶颈。

0
下载
关闭预览

相关内容

多样化偏好优化
专知会员服务
12+阅读 · 2025年2月3日
大型语言模型的高效提示方法综述
专知会员服务
75+阅读 · 2024年4月2日
【Google】高效Transformer综述,Efficient Transformers: A Survey
专知会员服务
66+阅读 · 2022年3月17日
【AAAI2021】对比聚类,Contrastive Clustering
专知
26+阅读 · 2021年1月30日
深度学习中Attention Mechanism详细介绍:原理、分类及应用
深度学习与NLP
10+阅读 · 2019年2月18日
Attention模型方法综述 | 多篇经典论文解读
PaperWeekly
107+阅读 · 2018年6月11日
深度学习的目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN
数据挖掘入门与实战
13+阅读 · 2018年4月6日
推荐|机器学习中的模型评价、模型选择和算法选择!
全球人工智能
10+阅读 · 2018年2月5日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
7+阅读 · 2015年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
VIP会员
最新内容
技术、多域威慑与海上战争(报告)
专知会员服务
1+阅读 · 今天15:04
“在云端防御”:提升北约数据韧性(报告)
专知会员服务
1+阅读 · 今天14:54
人工智能及其在海军行动中的整合(综述)
专知会员服务
0+阅读 · 今天14:07
美军MAVEN项目全面解析:算法战架构
专知会员服务
16+阅读 · 今天8:36
从俄乌战场看“马赛克战”(万字长文)
专知会员服务
10+阅读 · 今天8:19
相关VIP内容
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
7+阅读 · 2015年12月31日
国家自然科学基金
6+阅读 · 2014年12月31日
国家自然科学基金
2+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员