Reviewing rounds prediction for code patches

Yuan Huang, Xingjian Liang, Zhihao Chen, Nan Jia, Xiapu Luo, Xiangping Chen, Zibin Zheng, Xiaocong ZhouEmpir. Softw. Eng 2022

Abstract

Code review is a critical yet time-consuming phase in software development. While existing tools predict patch mergeability, they often overlook the effort required in terms of reviewing rounds. This paper presents PMCost, a machine learning framework designed to predict the number of review rounds a patch will undergo. By categorizing patches into low, medium, and high-effort groups using a diverse set of features—including metadata, code churn, developer experience, and textual semantics—PMCost achieves high accuracy across major open-source ecosystems, providing developers with actionable insights to streamline the review process.

Introduction: The Code Review Bottleneck

In modern software engineering, code review serves as the gold standard for maintaining quality. However, the process is often a notorious bottleneck. A developer submits a "patch," a reviewer suggests changes, and the cycle repeats through multiple "reviewing rounds." These cycles can stretch into weeks, stalling project timelines.

While tools exist to predict whether a patch will eventually be merged, there is a significant gap in predicting the effort required to reach that state. If developers could anticipate that a patch might trigger extensive debate (e.g., more than six rounds), they could proactively decompose the patch into smaller, simpler units or perform more rigorous self-inspections before submission.

Distribution of reviewing rounds across Eclipse, OpenDaylight, and OpenStack projects.

As shown in the distribution above, while many patches are resolved quickly, a significant tail of patches requires numerous rounds, representing a substantial drain on team resources.

Methodology: The PMCost Framework

The authors propose PMCost, which approaches the problem as a triple-classification task. Rather than attempting to predict an exact number of rounds—which proved inaccurate in early regression tests—the model classifies patches into three actionable categories:

  1. Low Effort: 1 round
  2. Medium Effort: 2–6 rounds
  3. High Effort: >6 rounds

Feature Extraction

The strength of PMCost lies in its multi-dimensional feature extraction process, which captures the technical and social context of a patch:

  • Patch Meta Features (PMF): Includes basic metadata such as submission time and "diffusion" (the breadth of the file tree affected by the patch).
  • Code Diff Features (CDF): Quantitative measures of "code churn," such as the number of modified methods, statements, and the ratio of changed lines.
  • Personal Experience Features (PEF): This includes historical submission counts and Social Network Analysis. By building collaboration graphs, the model calculates "centrality" metrics to measure how well-connected a developer or reviewer is within the project's ecosystem.
  • Textual Features (TF): Word2Vec embeddings are used to capture the semantic complexity of the developer's commit message.
The PMCost framework architecture, illustrating the model building and prediction phases.

After evaluating various classifiers, including SVM and MLP, the Random Forest algorithm was selected for its superior balance of precision and recall.

Dataset and Evaluation

The study analyzed over 50,000 review cases from three massive open-source ecosystems using the Gerrit review tool: Eclipse, OpenDaylight, and OpenStack. The final cleaned dataset comprised 19,964 patches submitted between 2017 and 2020.

PMCost achieved impressive accuracy across these diverse projects:

  • Eclipse: 79.83%
  • OpenDaylight: 72.97%
  • OpenStack: 71.81%

The model was particularly adept at identifying "one-round" patches, which helps reviewers prioritize "quick wins" to clear their queues efficiently.

Key Insights

  • Historical Predictors: The most predictive feature was AvgOwnerReviewRounds. A developer's past performance is a strong indicator of future review friction, often tied to individual habits or the complexity of the components they manage.
  • The Message Length Paradox: Longer commit messages often correlate with more review rounds. While documentation is valuable, excessive length frequently signals a patch that is too complex for easy digestion.
  • Social Connectivity: "Central" reviewers in the collaboration network tend to be involved in patches that progress faster, likely due to their deep familiarity with the codebase and team dynamics.

Conclusion and Future Work

A notable challenge identified is the "Newbie Bias," where the model struggles with developers lacking a submission history. The authors addressed this by implementing a fallback model that excludes experience features for new users. Future research will explore more granular code change types (e.g., refactoring vs. new features) and test the framework within proprietary industrial environments where social dynamics may differ from open-source communities.

Summary updated

BibTeX
@article{huang2022reviewing,
  author = {Yuan Huang and Xingjian Liang and Zhihao Chen and Nan Jia and Xiapu Luo and Xiangping Chen and Zibin Zheng and Xiaocong Zhou},
  title = {{Reviewing rounds prediction for code patches}},
  journal = {Empir. Softw. Eng.},
  year = {2022},
  doi = {10.1007/s10664-021-10035-z},
}
Figure