Machine learning on source code (MLOnCode) is a popular research field that has been driven by the availability of large-scale code repositories and the development of powerful probabilistic and deep learning models for mining source code. Code-to-code recommendation is a task in MLOnCode that aims to recommend relevant, diverse and concise code snippets that usefully extend the code currently being written by a developer in their development environment (IDE). Code-to-code recommendation engines hold the promise of increasing developer productivity by reducing context switching from the IDE and increasing code-reuse. Existing code-to-code recommendation engines do not scale gracefully to large codebases, exhibiting a linear growth in query time as the code repository increases in size. In addition, existing code-to-code recommendation engines fail to account for the global statistics of code repositories in the ranking function, such as the distribution of code snippet lengths, leading to sub-optimal retrieval results. We address both of these weaknesses with \emph{Senatus}, a new code-to-code recommendation engine. At the core of Senatus is \emph{De-Skew} LSH a new locality sensitive hashing (LSH) algorithm that indexes the data for fast (sub-linear time) retrieval while also counteracting the skewness in the snippet length distribution using novel abstract syntax tree-based feature scoring and selection algorithms. We evaluate Senatus and find the recommendations to be of higher quality than competing baselines, while achieving faster search. For example on the CodeSearchNet dataset Senatus improves performance by 31.21\% F1 and 147.9\emph{x} faster query time compared to Facebook Aroma. Senatus also outperforms standard MinHash LSH by 29.2\% F1 and 51.02\emph{x} faster query time.
翻译:源代码 (MLOnCode) 的机器学习是一个受欢迎的研究领域, 由大规模代码库库的可用性和采矿源代码开发强大的概率和深度学习模型驱动。 代码到代码建议是 MLOnCode 中的一项任务, 目的是推荐相关、 多样和简明的代码片段, 以有益的方式扩展当前开发者在其开发环境中正在编写的代码( IDE) 。 代码到代码建议引擎有希望提高开发器的生产率, 其方法是减少从 IDE 快速切换环境, 并增加代码重新使用。 现有的代码到代码建议引擎不会向大代码库放大, 随着代码存储器规模的扩大, 在查询时间里显示线上增长。 此外, 现有的代码到代码的引擎无法在排序函数中将代码存储器的全球统计数据包含在内端, 例如代码的缩略长度分布, 导致次最佳的检索结果 。 我们用\ emph{Senperatus 找到这些弱点, 新的代码到代码到编码建议引擎的长度, 在Sental deal deal develyal relix relial1 exalSdealxxxx dealx dealxxxxxxx dalxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx