Skip to main content
QUICK REVIEW

[论文解读] Towards Automated Performance Bug Identification in Python

Sokratis Tsakiltsidis, Andriy Miranskyy|arXiv (Cornell University)|Jul 28, 2016
Software Engineering Research参考文献 39被引用 8
一句话总结

本文提出一种机器学习方法,通过静态代码属性在开发早期检测Python代码中的性能错误。通过使用提交级别指标(如代码行数变更、文件年龄和文件大小)训练模型,C4.5决策树在预测性能错误方面实现了96%的精确率、85%的准确率和73%的召回率,表明功能缺陷预测技术可有效应用于非功能性的性能问题。

ABSTRACT

Context: Software performance is a critical non-functional requirement, appearing in many fields such as mission critical applications, financial, and real time systems. In this work we focused on early detection of performance bugs; our software under study was a real time system used in the advertisement/marketing domain. Goal: Find a simple and easy to implement solution, predicting performance bugs. Method: We built several models using four machine learning methods, commonly used for defect prediction: C4.5 Decision Trees, Na\"ıve Bayes, Bayesian Networks, and Logistic Regression. Results: Our empirical results show that a C4.5 model, using lines of code changed, file's age and size as explanatory variables, can be used to predict performance bugs (recall=0.73, accuracy=0.85, and precision=0.96). We show that reducing the number of changes delivered on a commit, can decrease the chance of performance bug injection. Conclusions: We believe that our approach can help practitioners to eliminate performance bugs early in the development cycle. Our results are also of interest to theoreticians, establishing a link between functional bugs and (non-functional) performance bugs, and explicitly showing that attributes used for prediction of functional bugs can be used for prediction of performance bugs.

研究动机与目标

  • 为解决实时系统中性能错误发现过晚且修复成本高昂的挑战。
  • 探究是否可利用静态代码分析和仓库度量来预测性能错误,类似于功能缺陷预测。
  • 识别与Python应用程序中性能错误引入相关的关键代码属性。
  • 为开发人员提供一种轻量级的早期预警系统,以在持续集成过程中预防性能回归。

提出的方法

  • 从一个三年期的实时竞价(RTB)系统中收集了2,800个文件提交,以提取静态代码和提交级别属性。
  • 将属性分类为项目、活动和经验三类,包括代码行数变更、文件年龄、文件大小和提交频率。
  • 对数据进行预处理,并训练了四种机器学习模型:C4.5决策树、朴素贝叶斯、贝叶斯网络和逻辑回归。
  • 使用标准指标(精确率、召回率和准确率)评估模型性能,并分析每种模型的特征重要性。
  • 识别并记录了11种Python中的性能优化模式,如避免重复的方法查找和使用就地操作。
  • 利用这些模式验证模型预测结果,并指导未来静态分析规则的开发。

实验结果

研究问题

  • RQ1是否可利用静态代码分析和仓库度量来预测Python应用程序中的性能错误?
  • RQ2在使用提交级别属性时,哪些机器学习模型在预测性能错误方面表现最佳?
  • RQ3哪些代码属性(例如代码行数变更、文件年龄)最能预测性能错误的引入?
  • RQ4是否可自动检测常见性能优化模式,并用于改进预测模型?

主要发现

  • C4.5决策树模型表现最佳,使用代码行数变更、文件年龄和文件大小作为预测变量,实现了96%的精确率、85%的准确率和73%的召回率。
  • 每次提交的变更数量越少,引入性能错误的可能性就越低。
  • 本研究证实,用于功能缺陷预测的属性(如代码变更量和文件年龄)同样可预测性能错误,建立了功能缺陷与非功能缺陷预测之间的联系。
  • 表现最佳的模型表明,高代码变更量(大量代码行数变更)与性能错误的引入密切相关。
  • 本研究在Python中识别出11种可重用的性能优化模式,如使用`map()`代替循环和缓存方法查找,可用于指导静态分析。
  • 结果表明,可利用轻量级静态度量将性能错误检测集成到CI/CD流水线的早期阶段,从而减少对昂贵运行时性能分析的依赖。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。