arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 1902.07808cs.PL
收藏

瞬态渐变分型的优化与评价

Optimizing and Evaluating Transient Gradual Typing

Michael M. Vitousek, Jeremy G. Siek, Avik Chaudhuri

摘要:

渐进类型使程序员能够在同一语言中组合静态和动态类型。然而,确保静态和动态部分之间的良好交互可能会导致显著的运行时成本。在本文中,我们对在Reticulated Python(Python的一个渐进类型变体)中实现的瞬态渐进类型化方法进行了详细的性能分析。瞬态方法在整个程序中插入轻量级检查,而不是在高阶值上安装代理。我们表明,当在CPython上运行Reticulated Python和瞬态方法时,随着程序从动态类型发展到静态类型,性能会下降,与等效的Python程序相比,速度会降低6倍。为了减少这种开销,我们设计了一个静态分析和优化,删除冗余的运行时检查。优化采用静态类型推断算法,解决了传统的子类型约束,也是一种新的检查约束。我们评估所产生的性能,并发现,对于许多程序,部分类型化的程序的效率是接近他们的非类型化的同行,消除了大部分的瞬态检查的减速。最后,我们测量了网格化Python程序在PyPy(一种跟踪JIT)上运行时的效率。我们发现,将PyPy与我们的类型推断算法相结合,可以将总体开销降低到零。

英文摘要:

Gradual typing enables programmers to combine static and dynamic typing in the same language. However, ensuring a sound interaction between the static and dynamic parts can incur significant runtime cost. In this paper, we perform a detailed performance analysis of the transient gradual typing approach implemented in Reticulated Python, a gradually typed variant of Python. The transient approach inserts lightweight checks throughout a program rather than installing proxies on higher order values. We show that, when running Reticulated Python and the transient approach on CPython, performance decreases as programs evolve from dynamic to static types, up to a 6x slowdown compared to equivalent Python programs. To reduce this overhead, we design a static analysis and optimization that removes redundant runtime checks. The optimization employs a static type inference algorithm that solves traditional subtyping constraints and also a new kind of check constraint. We evaluate the resulting performance and find that for many programs, the efficiency of partially typed programs is close to their untyped counterparts, removing most of the slowdown of transient checks. Finally, we measure the efficiency of Reticulated Python programs when running on PyPy, a tracing JIT. We find that combining PyPy with our type inference algorithm reduces the overall overhead to zero.

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

↑