paperbot · PL 论文追踪

全部论文 待读 收藏

P2 Bonsai: Compiling Queries to Pruned Tree Traversals

Bonsai:将查询编译为剪枝树遍历
PLDI 10(PLDI)2026匹配度 3/10 · 该论文用符号区间分析(抽象解释)自动推导树查询的剪枝条件并做编译融合,属于 PL/程序分析与编译优化的范畴,方法论上(静态分析、抽象解释)与用户背景有一定关联;但它面向数据库/查询优化的树遍历,完全未涉及 ML/Agentic 程序、LLM 辅助分析、浮点程序分析或贝叶斯程序分析等用户的核心交叉方向。引用 1 inbox
Alexander J Root, Christophe Gyurgyik, Purvi Goel, Kayvon Fatahalian, Jonathan Ragan-Kelley, Andrew Adams, Fredrik Kjolstad
crossref: 2026-09-10

AI 速览

一句话:用符号区间分析自动推导树元数据剪枝条件,并将复合查询编译融合为单次树遍历。

树结构可通过在节点上存储元数据来加速大集合上的搜索与聚合查询:当元数据上的谓词能证明某子树的数据全部无关(或全部相关)时,即可整棵剪枝或整体纳入。现有系统需要针对每种查询谓词与数据结构手工实现这套剪枝逻辑。本文提出 Bonsai,将这类优化推广并机械化:它以每个节点可用的元数据为输入,通过符号区间分析自动推导子树可被剪枝或整体包含的条件,并为此扩展了处理相交、包含等几何谓词的新规则;同时,编译器能把复合查询(如 filter 之上的 reduction)融合为一次树遍历。这些技术可自动导出广义的单索引与双索引树连接,支持远超等值与范围谓词的连接条件。生成的遍历与专家手写代码行为一致,并能在手写情形不适用时渐近优于线性扫描与嵌套循环连接。

问题
树上的剪枝式查询加速目前依赖人工为每个谓词和数据结构实现剪枝逻辑,难以推广与复用。
方法
从节点元数据出发,用扩展了几何谓词规则的符号区间分析自动推导剪枝/整体包含条件,并由编译器把复合查询融合成单一树遍历。
评估
将自动生成的遍历与专家手写实现对比,行为一致;在手工情形不适用时可渐近优于线性扫描与嵌套循环连接。
原文摘要(Abstract)

Trees can accelerate queries that search or aggregate values over large collections. They achieve this by storing metadata that enables quick pruning (or inclusion) of subtrees when predicates on that metadata can prove that none (or all) of the data in a subtree affect the query result. Existing systems implement this pruning logic manually for each query predicate and data structure. We generalize and mechanize this class of optimization. Our method derives conditions for when subtrees can be pruned (or included wholesale), expressed in terms of the metadata available at each node. We efficiently generate these conditions using symbolic interval analysis, extended with new rules to handle geometric predicates (e.g., intersection, containment). Additionally, our compiler fuses compound queries (e.g., reductions on filters) into a single tree traversal. These techniques enable the automatic derivation of generalized single-index and dual-index tree joins that support a wide class of join predicates beyond standard equality and range predicates. The generated traversals match the behavior of expert-written code that implements query-specific traversals, and can asymptotically outperform the linear scans and nested-loop joins that existing systems fall back to when hand-written cases do not apply.

链接与引用

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

BibTeX
@article{RootGGFRAK26,
  title = {Bonsai: Compiling Queries to Pruned Tree Traversals},
  author = {Alexander J Root and Christophe Gyurgyik and Purvi Goel and Kayvon Fatahalian and Jonathan Ragan-Kelley and Andrew Adams and Fredrik Kjolstad},
  journal = {Proceedings of the ACM on Programming Languages},
  volume = {10},
  number = {PLDI},
  year = {2026},
  doi = {10.1145/3808256}
}