paperbot · PL 论文追踪

全部论文 待读 收藏

P2 AST vs. Bytecode: Interpreters in the Age of Meta-Compilation

AST 与字节码:元编译时代的解释器
OOPSLA 7(OOPSLA2)2023匹配度 1/10 · 论文研究 AST 与字节码解释器在 RPython/GraalVM 元编译系统中的性能与内存权衡,属于程序语言、编译器与运行时方向;但未涉及静态分析、LLM/Agent、浮点程序分析或贝叶斯程序分析,与用户当前核心研究方向基本无关。引用 9 inbox
Octave Larose, Sophie Kaleba, Humphrey Burchell, Stefan Marr
crossref: 2026-09-10

AI 速览

一句话:通过 RPython 与 GraalVM 实现成对解释器,实证 AST 解释器在元编译系统中与字节码解释器性能相当且内存权衡不同。

元编译与元追踪使仅实现解释器即可获得接近最先进的峰值性能,但此类系统仍需改善内存占用与预热。论文检验“字节码解释器在内存和运行时性能上优于 AST 解释器”的假设,在 RPython 与 GraalVM 上分别实现 AST 与字节码解释器,并尽量缩小二者差异,以评估纯解释器性能、峰值性能、预热、内存占用及单项优化影响。结果显示,两系统均接近 Node.js/V8;纯解释执行时 AST 解释器与字节码相当甚至略快,JIT 后大致持平,说明字节码并无普遍性能优势。字节码在内存中更紧凑,利于大型应用;但小型应用因装箱消除受限及具象化栈等结构,字节码解释器反而分配更多内存。

问题
元编译系统虽能降低语言实现成本,但仍需改善内存占用和预热;核心问题是 AST 与字节码解释器在性能与内存上的权衡是否如传统假设所说偏向字节码。
方法
作者用 RPython 和 GraalVM 各实现一对 AST/字节码解释器,控制实现差异,比较纯解释执行、JIT 后峰值性能、预热、内存使用及单项优化。
评估
在两类元编译系统上与 Node.js/V8 对比,发现 AST 解释器纯解释性能与字节码相当或略快,JIT 后持平;字节码更紧凑但在小型应用上内存分配更多。
原文摘要(Abstract)

Thanks to partial evaluation and meta-tracing, it became practical to build language implementations that reach state-of-the-art peak performance by implementing only an interpreter. Systems such as RPython and GraalVM provide components such as a garbage collector and just-in-time compiler in a language-agnostic manner, greatly reducing implementation effort. However, meta-compilation-based language implementations still need to improve further to reach the low memory use and fast warmup behavior that custom-built systems provide. A key element in this endeavor is interpreter performance. Folklore tells us that bytecode interpreters are superior to abstract-syntax-tree (AST) interpreters both in terms of memory use and run-time performance. This work assesses the trade-offs between AST and bytecode interpreters to verify common assumptions and whether they hold in the context of meta-compilation systems. We implemented four interpreters, each an AST and a bytecode one using RPython and GraalVM. We keep the difference between the interpreters as small as feasible to be able to evaluate interpreter performance, peak performance, warmup, memory use, and the impact of individual optimizations. Our results show that both systems indeed reach performance close to Node.js/V8. Looking at interpreter-only performance, our AST interpreters are on par with, or even slightly faster than their bytecode counterparts. After just-in-time compilation, the results are roughly on par. This means bytecode interpreters do not have their widely assumed performance advantage. However, we can confirm that bytecodes are more compact in memory than ASTs, which becomes relevant for larger applications. However, for smaller applications, we noticed that bytecode interpreters allocate more memory because boxing avoidance is not as applicable, and because the bytecode interpreter structure requires memory, e.g., for a reified stack. Our results show AST interpreters to be competitive on top of meta-compilation systems. Together with possible engineering benefits, they should thus not be discounted so easily in favor of bytecode interpreters.

链接与引用

DOI 原文 · PDF(开放获取) ·

BibTeX
@article{paperbot1892,
  title = {AST vs. Bytecode: Interpreters in the Age of Meta-Compilation},
  author = {Octave Larose and Sophie Kaleba and Humphrey Burchell and Stefan Marr},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {7},
  number = {OOPSLA2},
  year = {2023},
  doi = {10.1145/3622808}
}