Skip to main content
QUICK REVIEW

[Paper Review] SourcererCC: Scaling Code Clone Detection to Big Code

Hitesh Sajnani, Vaibhav Saini|arXiv (Cornell University)|Dec 20, 2015
Software Engineering ResearchComputer Science41 references294 citations
TL;DR

SourcererCC is a scalable, token-based clone detection tool that uses an optimized inverted index and token-ordering heuristics to detect exact and near-miss (Type-3) code clones in large inter-project repositories. It achieves high recall and precision on 250MLOC of code using a single workstation, outperforming existing tools in scalability and accuracy for general-purpose clone detection.

ABSTRACT

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.

Motivation & Objective

  • To address the lack of scalable, accurate clone detectors capable of handling large inter-project repositories with near-miss clones.
  • To develop a general-purpose clone detection tool that supports Type-3 (near-miss) clones without requiring distributed computing.
  • To achieve high recall and precision while operating efficiently on standard hardware, avoiding the complexity and cost of cluster-based setups.
  • To enable practical use in software maintenance, fork management, and large-scale code analysis by researchers and developers.

Proposed method

  • SourcererCC uses a bag-of-tokens approach to represent code blocks, making it resilient to minor syntactic changes common in Type-3 clones.
  • It builds a partial inverted index over tokens to enable fast querying of potential clone candidates for any given code block.
  • Filtering heuristics based on token ordering reduce index size and eliminate many false positives early, minimizing full code-block comparisons.
  • A live upper bound on similarity is computed using token order to reject or accept candidates with fewer token comparisons.
  • The system is implemented in two variants: SourcererCC-B for batch analysis and SourcererCC-I for interactive IDE integration in Eclipse.
  • The tool is designed to be programming language-agnostic and operates without distribution, enabling deployment on standard workstations.

Experimental results

Research questions

  • RQ1Can a token-based clone detection system achieve high recall and precision for Type-3 clones at scale on a single machine?
  • RQ2How does the performance of SourcererCC compare to state-of-the-art tools in terms of scalability, execution time, recall, and precision?
  • RQ3To what extent do filtering heuristics based on token ordering reduce index size and comparison overhead?
  • RQ4Can SourcererCC detect clones in a large inter-project repository (e.g., 250MLOC) without distributed infrastructure?

Key findings

  • SourcererCC successfully detected clones in a 250MLOC inter-project repository (IJaDataset-2.0) using only a standard workstation, completing the analysis in 4.5 days.
  • The tool achieved high recall on two benchmarks: BigCloneBench and a mutation/injection-based framework of fine-grained artificial clones.
  • Precision was validated by multiple clone experts, confirming strong agreement and reliability in clone detection results.
  • The optimized index was only 1.2GB in size for 18GB of source code, demonstrating significant space efficiency compared to prior index-based approaches.
  • SourcererCC outperformed four state-of-the-art tools in both recall and precision, particularly in detecting Type-3 clones.
  • The filtering heuristics reduced the number of required code-block comparisons and token comparisons, significantly improving performance.

Better researchstarts right now

From reading papers to final review, dramatically reduce your research time.

No credit card · Free plan available

This review was created by AI and reviewed by human editors.