University of Limerick
Browse
- No file added yet -

Nearest-neighbor, BERT-based, scalable clone detection: A practical approach for large-scale industrial code bases

Download (2.29 MB)
journal contribution
posted on 2024-06-18, 10:16 authored by Gul Aftab Ahmed, James Vincent PattenJames Vincent Patten, Yuanhua Han, Guoxian Lu, Wei Hou, David Gregg, Jim BuckleyJim Buckley, Muslim ChochlovMuslim Chochlov

Hidden code clones negatively impact software maintenance, but manually detecting them in large codebases is impractical. Additionally, automated approaches find detection of syntactically-divergent clones very challenging. While recent deep neural networks (for example BERT-based artificial neural networks) seem more effective in detecting such clones, their pairwise comparison of every code pair in the target system(s) is inefficient and scales poorly on large codebases. We present SSCD, a BERT-based clone detection approach that targets high recall of Type 3 and Type 4 clones at a very large scale (in line with our industrial partner’s requirements). It computes a representative embedding for each code fragment and finds similar fragments using a nearest neighbor search. Thus, SSCD avoids the pairwise-comparison bottleneck of other neural network approaches, while also using a parallel, GPU-accelerated search to tackle scalability. This article describes the approach, proposing and evaluating several refinements to improve Type 3/4 clone detection at scale. It provides a substantial empirical evaluation of the tech?nique, including a speed/efficacy comparison of the approach against SourcererCC and Oreo, the only other neural-network approach currently capable of scaling to hundreds of millions of LOC. It also includes a large in-situ evaluation on our industrial collaborator’s code base that assesses the original technique, the impact of the proposed refinements and illustrates the impact of incremental, active learning on its efficacy. We find that SSCD is significantly faster and more accurate than SourcererCC and Oreo. SAGA, a GPU-accelerated traditional clone detection approach, is a little better than SSCD for T1/T2 clones, but substantially worse for T3/T4 clones. Thus, SSCD is both scalable to industrial code sizes, and comparatively more accurate than existing approaches for difficult T3/T4 clone searching. In-situ evaluation on company datasets shows that SSCD outperforms the baseline approach (CCFinderX) for T3/T4 clones. Whitespace removal and active learning further improve SSCD effectiveness.

Funding

Confirm Centre for Smart Manufacturing

Science Foundation Ireland

Find out more...

History

Publication

Software: Practice and Experience pp.1-26

Publisher

John Wiley & Sons Ltd

Department or School

  • Computer Science & Information Systems

Usage metrics

    University of Limerick

    Categories

    Exports

    RefWorks
    BibTeX
    Ref. manager
    Endnote
    DataCite
    NLM
    DC