paperbot · PL 论文追踪

全部论文 待读 收藏

P2 HyperDiff: Computing Source Code Diffs at Scale

HyperDiff:大规模计算源代码差异
FSE Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering2023匹配度 3/10 · 该论文属于程序分析基础设施层面的通用代码差异计算(增量、可扩展的 AST diff),与用户关注的 ML/Agentic 程序静态分析、LLM 与静态分析/浮点/贝叶斯分析交叉等核心问题没有直接关联;虽属 PL 领域且有较强的工程实现与规模化评测,但既未涉及 LLM/Agent,也未针对 ML 系统或特定分析任务。引用 6 inbox
Quentin Le Dilavrec, Djamel Eddine Khelladi, Arnaud Blouin, Jean-Marc Jézéquel
crossref: 2026-09-12dblp: 2026-09-12

AI 速览

一句话:提出基于 HyperAST 的增量、内存友好代码差异计算,使 GumTree 式 diff 可扩展到大型代码历史。

面向时间的代码分析(如缺陷归因、缺陷预测与代码演化分析)需要计算大量版本间的代码差异,但逐版本解析 AST 并重复计算差异造成严重可扩展性瓶颈。本文提出 HyperDiff,利用表示代码历史的 HyperAST 这一面向时间的数据结构,将主流 GumTree 差异算法惰性化,从而实现增量且内存高效的差异计算。作者在 19 个大型软件项目上与 GumTree 对比评估。结果表明,该方法在时间与内存上均优于 GumTree:总 diff 计算 CPU 时间加速 1.2 至 12.7 倍,中间阶段最高加速 226 倍,每 AST 节点的内存占用相差 4.5 倍,且与 GumTree 产生 99.3% 相同的 diff。

问题
如何高效计算大量代码版本间的 diff,避免重复解析与重复计算,使面向时间的代码分析可扩展到大型软件项目。
方法
基于 HyperAST 代码历史表示,将 GumTree 差异算法惰性化,设计增量且内存友好的差异计算流程。
评估
在 19 个大型软件项目上与 GumTree 对比,报告 CPU 时间、内存占用与 diff 一致性。
原文摘要(Abstract)

With the advent of fast software evolution and multistage releases, temporal code analysis is becoming useful for various purposes, such as bug cause identification, bug prediction or code evolution analysis. Temporal code analyses can consist in analyzing multiple Abstract Syntax Trees (ASTs) extracted from code evolutions, e.g. one AST for each commit or release. Core feature to temporal analysis is code differencing: the computation of the so-called Diff or edit script between two given versions of the code. However, jointly analyzing and computing the difference on thousands versions of code faces scalability issues. Mainly because of the cost of: 1) parsing the original and evolved code in two source and target ASTs; 2) wasting resources by not reusing intermediate computation results that can be shared between versions. This paper details a novel approach based on time-oriented data structures that makes code differencing scale up to large software codebases. In particular, we leverage on the HyperAST, a novel representation of code histories, to propose an incremental and memory efficient approach by lazifying the well known GumTree diffing algorithms, a mainstream code differencing algorithm and tool. We evaluated our approach on a curated list of 19 large software projects and compared it to GumTree. Our approach outperforms it in scalability both in time and memory. We observed an order-of-magnitude difference: 1) in CPU time from x1.2 to x12.7 for the total time of diff computation and up to x226 in intermediate phases of the diff computation, and 2) in memory footprint of x4.5 per AST node. The approach produced 99.3% of identical diffs with respect to GumTree.

链接与引用

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

BibTeX
@inproceedings{DilavrecKBJ23,
  title = {HyperDiff: Computing Source Code Diffs at Scale},
  author = {Quentin Le Dilavrec and Djamel Eddine Khelladi and Arnaud Blouin and Jean-Marc Jézéquel},
  booktitle = {FSE},
  year = {2023},
  doi = {10.1145/3611643.3616312}
}