[论文解读] SourcererCC: Scaling Code Clone Detection to Big Code
SourcererCC 是一种可扩展的基于标记的克隆检测工具,利用优化的倒排索引和标记顺序启发式方法,在大型跨项目仓库中检测精确克隆和近似克隆(Type-3)代码。它在单台工作站上处理 2.5 亿行代码时实现了高召回率和高精确率,相较于现有工具在可扩展性和准确性方面表现更优,适用于通用克隆检测。
Despite a decade of active research, there is a marked lack in clone detectors that scale to very large repositories of source code, in particular for detecting near-miss clones where significant editing activities may take place in the cloned code. We present SourcererCC, a token-based clone detector that targets three clone types, and exploits an index to achieve scalability to large inter-project repositories using a standard workstation. SourcererCC uses an optimized inverted-index to quickly query the potential clones of a given code block. Filtering heuristics based on token ordering are used to significantly reduce the size of the index, the number of code-block comparisons needed to detect the clones, as well as the number of required token-comparisons needed to judge a potential clone. We evaluate the scalability, execution time, recall and precision of SourcererCC, and compare it to four publicly available and state-of-the-art tools. To measure recall, we use two recent benchmarks, (1) a large benchmark of real clones, BigCloneBench, and (2) a Mutation/Injection-based framework of thousands of fine-grained artificial clones. We find SourcererCC has both high recall and precision, and is able to scale to a large inter-project repository (250MLOC) using a standard workstation.
研究动机与目标
- 解决缺乏可扩展、高精度克隆检测器的问题,这些检测器能够处理包含近似克隆的大型跨项目仓库。
- 开发一种通用克隆检测工具,支持 Type-3(近似)克隆,且无需依赖分布式计算。
- 在标准硬件上高效运行,实现高召回率和高精确率,避免集群部署带来的复杂性和成本。
- 通过研究人员和开发人员在软件维护、分支管理及大规模代码分析中的实际应用,实现工具的实用化。
提出的方法
- SourcererCC 使用基于标记的词袋方法表示代码块,使其对 Type-3 克隆中常见的微小语法变化具有鲁棒性。
- 构建基于标记的局部倒排索引,以实现对任意给定代码块的潜在克隆候选的快速查询。
- 基于标记顺序的过滤启发式方法可减少索引大小,并早期消除大量误报,从而最小化完整代码块比较的次数。
- 通过标记顺序计算相似性的实时上界,以更少的标记比较次数快速拒绝或接受候选。
- 系统实现为两种变体:SourcererCC-B 用于批处理分析,SourcererCC-I 用于在 Eclipse 中的交互式 IDE 集成。
- 该工具设计为与编程语言无关,无需分发,可在标准工作站上轻松部署。
实验结果
研究问题
- RQ1基于标记的克隆检测系统是否能在单台机器上实现对 Type-3 克隆的高召回率和高精确率?
- RQ2SourcererCC 在可扩展性、执行时间、召回率和精确率方面与最先进工具相比表现如何?
- RQ3基于标记顺序的过滤启发式方法在多大程度上减少了索引大小和比较开销?
- RQ4SourcererCC 是否能够在无分布式基础设施支持的情况下检测大型跨项目仓库(如 2.5 亿行代码)中的克隆?
主要发现
- SourcererCC 仅使用标准工作站便成功检测了 2.5 亿行代码的跨项目仓库(IJaDataset-2.0),在 4.5 天内完成分析。
- 该工具在两个基准测试中均实现了高召回率:BigCloneBench 和基于变异/注入的细粒度人工克隆框架。
- 精确率经多位克隆检测专家验证,确认检测结果具有高度一致性和可靠性。
- 优化后的索引在 18GB 源代码下仅占用 1.2GB 空间,相较于以往基于索引的方法展现出显著的空间效率。
- SourcererCC 在召回率和精确率方面均优于四种最先进工具,尤其在检测 Type-3 克隆方面表现突出。
- 过滤启发式方法显著减少了所需代码块比较和标记比较的次数,大幅提升了性能。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。