Optimizing and Evaluating Transient Gradual Typing

02/20/2019
by   Michael M. Vitousek, et al.
0

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.

READ FULL TEXT
POST COMMENT

Comments

There are no comments yet.

Authors

11/19/2021

A Transient Semantics for Typed Racket

Mixed-typed languages enable programmers to link typed and untyped compo...
05/01/2020

Automatically Eliminating Speculative Leaks With Blade

We introduce BLADE, a new approach to automatically and efficiently synt...
09/12/2019

Which of My Transient Type Checks Are Not (Almost) Free?

One form of type checking used in gradually typed language is transient ...
02/18/2018

Efficient Gradual Typing

Gradual typing combines static and dynamic typing in the same program. O...
01/12/2021

Type4Py: Deep Similarity Learning-Based Type Inference for Python

Dynamic languages, such as Python and Javascript, trade static typing fo...
07/24/2020

Corpse Reviver: Sound and Efficient Gradual Typing via Contract Verification

Gradually-typed programming languages permit the incremental addition of...
02/28/2021

PyCG: Practical Call Graph Generation in Python

Call graphs play an important role in different contexts, such as profil...
This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.