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.
翻译:即时编程系统旨在快速向程序员展示代码编辑的动态影响。为此,每当程序被编辑时,系统会重新执行程序,这在程序规模变大或复杂度增加时带来了计算挑战。这促使即时编程解释器的实现需要具备增量性。本文提出Chordata——一种基于捷径记忆化技术的增量式程序解释器,它通过观察程序先前版本的执行过程,学习重复出现的计算模式(即捷径),并在相同或结构相似的程序片段被重新执行时应用这些捷径。本文为任何基于重写语义的语言贡献了捷径记忆化技术的形式化语义,并给出了关键正确性属性的机械化证明。随后,我们将Hazel即时编程系统的一个变体(以CEK机器形式表述)在Chordata中实现,并开发了多种实用启发式策略来学习高价值捷径。我们利用学生解决简单编程问题的编辑轨迹对所提出系统进行了评估。与基线相比,Chordata实现了13.03倍的加速比,同时带来19.97倍的内存开销。对于微小修改和更复杂的程序,Chordata甚至能获得更高加速比。此外,我们证明Chordata即使在单次执行中也能提供加速效果,且输入规模越大加速比越显著。