一句话:提出基于 lambda 演算的机会式求值策略,自动并行分派独立外部调用并流式返回结果,并用 Opal 语言验证。
脚本语言常用于组合本地库、网络服务等外部调用,其执行时间往往被等待外部调用所主导,传统的单语言优化因此收效甚微。本文提出一种面向脚本语言的机会式(opportunistic)求值策略,建立在一个核心 lambda 演算之上:它自动识别相互独立的外部调用并并行分派,同时以流式方式返回结果。作者证明了该策略具有合流性,从而保证不改变程序员原本的语义意图,并证明每个外部调用最终都会被执行。该策略被实现为脚本语言 Opal。评估聚焦于调用 LLM 和其他 API 等重外部计算的程序:在五个脚本上对比多个先进基线,相比顺序执行的 Python,总运行时间最高提升 6.2 倍、延迟最高提升 12.7 倍,同时相比手工调优的异步 Rust 仅多出 1.3%–18.5% 的运行时间开销;在 Tree-of-Thoughts 这一 LLM 推理方法上,相比作者自己的实现取得 6.2 倍加速。
Scripting languages are widely used to compose external calls such as native libraries and network services. In such scripts, execution time is often dominated by waiting for these external calls, rendering traditional single-language optimizations ineffective. To address this, we propose a novel opportunistic evaluation strategy for scripting languages based on a core lambda calculus that automatically dispatches independent external calls in parallel and streams their results. We prove that our approach is confluent, ensuring that it preserves the programmer’s original intent, and that it eventually executes every external call. We implement this approach in a scripting language called Opal . We demonstrate the versatility and performance of Opal , focusing on programs that invoke heavy external computation through the use of large language models (LLMs) and other APIs. Across five scripts, we compare to several state-of-the-art baselines and show that opportunistic evaluation improves total running time (up to 6.2×) and latency (up to 12.7×) compared to standard sequential Python, while performing very close (between 1.3% and 18.5% running time overhead) to hand-tuned manually optimized asynchronous Rust. For Tree-of-Thoughts, a prominent LLM reasoning approach, we achieve a 6.2 × performance improvement over the authors’ own implementation.
@article{paperbot3026,
title = {Opportunistically Parallel Lambda Calculus},
author = {Stephen Mell and Konstantinos Kallas and Steve Zdancewic and Osbert Bastani},
journal = {Proceedings of the ACM on Programming Languages},
volume = {9},
number = {OOPSLA2},
year = {2025},
doi = {10.1145/3763143}
}