arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2410.02232cs.PL
收藏

去森林化的漫漫长路(技术报告):一种用于移除中间数据结构的类型推断与精化技术

The Long Way to Deforestation (Technical Report): A Type Inference and Elaboration Technique for Removing Intermediate Data Structures

HKUST(香港科技大学)

Yijia Chen, Lionel Parreaux

AI总结:

针对函数式程序去森林化优化,提出基于子类型推断与精化融合的Lumberhack方法,可融合相互递归定义并避免代码重复,经逻辑关系证明可靠且在nofib基准上显著加速。

摘要:

去森林化是一种编译器优化技术,它从函数式程序中移除中间数据结构的分配以提高其效率。这是一个古老的想法,但先前的方法已被证明是有限或不切实际的:它们要么只适用于预定义组合子的组合(快捷融合),要么涉及对递归定义进行激进的展开,直到达到深度限制或发现重复模式以系紧递归结,导致不切实际的算法复杂性和大量代码重复。我们提出了Lumberhack,一种针对纯函数式按值调用程序的通用去森林化方法。Lumberhack使用子类型推断来推理数据结构的生产与消费,并使用精化(elaboration)过程来融合相应的递归定义。它融合了大规模相互递归定义类别,同时避免了先前方法中固有的许多无生产性(有时甚至适得其反)的代码重复。我们使用逻辑关系证明了Lumberhack的可靠性,并在标准nofib基准套件中实验性地展示了显著的加速效果。

英文摘要:

Deforestation is a compiler optimization that removes intermediate data structure allocations from functional programs to improve their efficiency. This is an old idea, but previous approaches have proved limited or impractical: they either only worked on compositions of predefined combinators (shortcut fusion), or involved the aggressive unfolding of recursive definitions until a depth limit was reached or a reoccurring pattern was found to tie the recursive knot, resulting in impractical algorithmic complexity and large amounts of code duplication. We present Lumberhack, a general-purpose deforestation approach for purely functional call-by-value programs. Lumberhack uses subtype inference to reason about data structure production and consumption and uses an elaboration pass to fuse the corresponding recursive definitions. It fuses large classes of mutually recursive definitions while avoiding much of the unproductive (and sometimes counter-productive) code duplication inherent in previous approaches. We prove the soundness of Lumberhack using logical relations and experimentally demonstrate significant speedups in the standard nofib benchmark suite.

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

↑