TY - JOUR
T1 - Nearest-neighbor, BERT-based, scalable clone detection
T2 - A practical approach for large-scale industrial code bases
AU - Ahmed, Gul Aftab
AU - Patten, James Vincent
AU - Han, Yuanhua
AU - Lu, Guoxian
AU - Hou, Wei
AU - Gregg, David
AU - Buckley, Jim
AU - Chochlov, Muslim
N1 - Publisher Copyright:
© 2024 The Author(s). Software: Practice and Experience published by John Wiley & Sons Ltd.
PY - 2024/12
Y1 - 2024/12
N2 - 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 technique, 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.
AB - 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 technique, 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.
KW - clone detection
KW - deep neural networks
KW - scalable
KW - semantic clones
UR - http://www.scopus.com/inward/record.url?scp=85195652866&partnerID=8YFLogxK
U2 - 10.1002/spe.3355
DO - 10.1002/spe.3355
M3 - Article
AN - SCOPUS:85195652866
SN - 0038-0644
VL - 54
SP - 2349
EP - 2374
JO - Software - Practice and Experience
JF - Software - Practice and Experience
IS - 12
ER -