一句话:提出 MergeBERT,将合并冲突消解重构为原始合并模式分类任务,准确率达 63–68%,远超已有工具。
协同开发中,多位开发者修改同一代码区域会产生合并冲突,导致 pull request 与持续集成流水线阻塞数小时乃至数天,严重损害开发效率。本文提出 MergeBERT:一个基于 token 级三方差分与 transformer 编码器的神经程序合并框架。作者利用合并冲突消解方案受限的特点,把生成消解序列的任务重新表述为对一组从真实合并提交数据中抽取的原始合并模式的分类任务。该模型在合并消解合成上达到 63–68% 的准确率,相比已有的半结构化方法提升近 3 倍,相比神经程序合并工具提升约 2 倍,并可跨 Java、JavaScript、TypeScript 与 C# 源码文件工作。为评估其实用性,作者对来自大型开源项目的 25 名开发者开展用户研究,覆盖他们遇到的 122 个真实冲突,结果表明实践中 MergeBERT 的消解建议的接受率高于自动精度与准确率指标所估计的水平,作者也据此总结了未来改进方向。
Collaborative software development is an integral part of the modern software development life cycle, essential to the success of large-scale software projects. When multiple developers make concurrent changes around the same lines of code, a merge conflict may occur. Such conflicts stall pull requests and continuous integration pipelines for hours to several days, seriously hurting developer productivity. To address this problem, we introduce MergeBERT, a novel neural program merge framework based on token-level three-way differencing and a transformer encoder model. By exploiting the restricted nature of merge conflict resolutions, we reformulate the task of generating the resolution sequence as a classification task over a set of primitive merge patterns extracted from real-world merge commit data. Our model achieves 63–68% accuracy for merge resolution synthesis, yielding nearly a 3× performance improvement over existing semi-structured, and 2× improvement over neural program merge tools. Finally, we demonstrate that MergeBERT is sufficiently flexible to work with source code files in Java, JavaScript, TypeScript, and C# programming languages. To measure the practical use of MergeBERT, we conduct a user study to evaluate MergeBERT suggestions with 25 developers from large OSS projects on 122 real-world conflicts they encountered. Results suggest that in practice, MergeBERT resolutions would be accepted at a higher rate than estimated by automatic metrics for precision and accuracy. Additionally, we use participant feedback to identify future avenues for improvement of MergeBERT.
@inproceedings{paperbot7059,
title = {Program merge conflict resolution via neural transformers},
author = {Alexey Svyatkovskiy and Sarah Fakhoury and Negar Ghorbani and Todd Mytkowicz and Elizabeth Dinella and Christian Bird and Jinu Jang and Neel Sundaresan and Shuvendu K. Lahiri},
booktitle = {FSE},
year = {2022},
doi = {10.1145/3540250.3549163}
}