Table of Contents
Fetching ...

Incremental Live Programming via Shortcut Memoization

Marisa Kirisame, Thomas J. Porter, Ruqing Yang, Jianqiu Zhao, Yudi Wu, Ivan Wei, Cyrus Omar, Pavel Panchekha

Abstract

Live programming systems aim to quickly show programmers the dynamic impacts of program edits. To do so, they re-execute the program whenever it is edited, which poses a computational challenge when programs become large or complex. This has led to the need for incrementality in the implementation of live program interpreters. This paper introduces Chordata, an incremental program interpreter based on shortcut memoization, which learns repeated patterns of computation, called shortcuts, by observing executions of previous versions of a program. It can then apply these shortcuts when the same or a structurally similar program fragment is re-executed. This paper contributes a formal semantics of shortcut memoization for any language with a rewrite-based semantics, with mechanized proofs of key correctness properties. We then express a variant of the Hazel live programming system, expressed as a CEK machine, in Chordata, and develop a number of practical heuristics to learn high-value shortcuts. We evaluate the resulting system on editing traces of students solving simple programming problems. Chordata achieves a speedup of 13.03\times compared to baseline with a 19.97\times memory overhead. For smaller changes and for more complex programs, Chordata achieves even greater speedups. Furthermore, we show that Chordata is capable of providing a speedup even within a single execution, with a faster speedup on a larger input.

Incremental Live Programming via Shortcut Memoization

Abstract

Live programming systems aim to quickly show programmers the dynamic impacts of program edits. To do so, they re-execute the program whenever it is edited, which poses a computational challenge when programs become large or complex. This has led to the need for incrementality in the implementation of live program interpreters. This paper introduces Chordata, an incremental program interpreter based on shortcut memoization, which learns repeated patterns of computation, called shortcuts, by observing executions of previous versions of a program. It can then apply these shortcuts when the same or a structurally similar program fragment is re-executed. This paper contributes a formal semantics of shortcut memoization for any language with a rewrite-based semantics, with mechanized proofs of key correctness properties. We then express a variant of the Hazel live programming system, expressed as a CEK machine, in Chordata, and develop a number of practical heuristics to learn high-value shortcuts. We evaluate the resulting system on editing traces of students solving simple programming problems. Chordata achieves a speedup of 13.03\times compared to baseline with a 19.97\times memory overhead. For smaller changes and for more complex programs, Chordata achieves even greater speedups. Furthermore, we show that Chordata is capable of providing a speedup even within a single execution, with a faster speedup on a larger input.
Paper Structure (34 sections, 3 theorems, 16 equations, 6 figures, 1 table)

This paper contains 34 sections, 3 theorems, 16 equations, 6 figures, 1 table.

Key Result

theorem 1

If $r_1\equiv r_1'$, $r_2\equiv r_2'$, $r_1\circ r_2 = r$, and $r_1'\circ r_2'\equiv r'$, then $r\equiv r'$.

Figures (6)

  • Figure 1: Screenshot of implementing quicksort in the Hazel live programming environment. While the user is editing the function, the program is incomplete (the hole at the red cursor on the left) and/or ill typed (not shown). The user can insert a probe to receive live feedback about a component of the result of calling partition, here s. As the user fills in the remaining function (right), Hazel will re-execute the program on every keystroke, updating the probe (here, showing that there are 8 total probed values available rather than the initial 2 from the tests shown). Currently, Hazel does a full re-execution on every keystroke, which can have high latency even for small programs, e.g. when there are many tests being run (elided here). The aim of Chordata is to speed up these re-executions by learning shortcuts from prior executions.
  • Figure 2: A discrimination tree holding three rewrite rules.
  • Figure 3: Chordata's internal term representation, which allows efficient wrapping and unwrapping of multiple constructors in a combined operation. In this example, wrapping the term in $Cons(0,\_)$ prepends two constructor nodes ($Cons$ and $0$), and the binary tree structure provides a logarithmic time append operation.
  • Figure 4: Results for the live-programming benchmark.
  • Figure 5: The scatterplot for the algebraic simplification benchmark
  • ...and 1 more figures

Theorems & Definitions (9)

  • definition 1
  • definition 2
  • definition 3
  • definition 4
  • definition 5
  • theorem 1: Compatibility of Rule Composition
  • theorem 2: Shortcut Existence
  • definition 6
  • theorem 3: Shortcut Validity