Continuously Learning Bug Locations

Paulina Stevia Nouwou Mindom, Leuson Da Silva, Amin Nikanjam, Foutse KhomharXiv 2024

TL;DR

Standard deep learning models for bug localization degrade over time because software code constantly evolves—a phenomenon known as concept drift. This paper introduces a Continual Learning (CL) framework using Deep Reinforcement Learning to adapt to changing codebases without forgetting past knowledge. By combining CL with traditional bug-inducing metrics, the authors achieve massive performance boosts on non-stationary data while cutting training times by up to 5x.

What Problem Does This Paper Address?

Automated bug localization tools are a lifesaver for developers, helping them pinpoint which files or code snippets (hunks) are responsible for a reported bug. Modern approaches use Deep Learning (DL) to link the natural language in bug reports to source code changesets.

However, these models suffer from a fatal flaw: they assume a stationary environment. In reality, codebases are highly dynamic. Between the time a bug is reported and when it is fixed, other developers are constantly modifying, adding, or deleting code. This shift in data distribution over time is called concept drift. When traditional DL models face this non-stationary data, their localization accuracy plummets. Retraining these models from scratch every time code changes is too computationally expensive, creating a clear need for models that can learn continuously.

Fig. 1. Performance of state-of-art baseline studies on Eclipse project.

Methods

The authors tackle this challenge by framing bug localization as a Deep Reinforcement Learning (DRL) problem where an agent sequentially selects and ranks code changesets based on their relevance to a bug report. To handle concept drift, they integrate two prominent Continual Learning (CL) paradigms:

  1. CLEAR (Continual Learning with Experience and Replay): An actor-critic model that mixes new experiences with replayed past experiences. It uses an off-policy algorithm called V-Trace to correct the distribution shifts caused by older data.
  2. EWC (Elastic Weight Consolidation): A regularization technique that calculates which neural network weights were crucial for past tasks and penalizes the model if it tries to alter them too drastically while learning new tasks.

As a novel enhancement, the authors also train a classic statistical logistic regression model using known bug-inducing factors (like code churn and pre-release bug history). The output of this model is injected directly into the DRL agent's reward function, giving the agent an extra "hint" to prioritize inherently risky files.

Fig. 2. Illustration of the CL framework.

Datasets

The framework was evaluated on seven large-scale open-source Java projects from the Apache and Eclipse ecosystems:

  • AspectJ, Birt, Eclipse (Platform UI), SWT, Tomcat, PDE, and Zxing.

To realistically simulate code evolution, the authors explicitly mined non-stationary data by collecting every single commit made between the date a bug was reported and the date it was finally resolved. The datasets were split chronologically (60% training, 40% testing) to ensure no future data leaked into past training cycles.

Key Insights and Ideas

  • Concept Drift is a Silent Killer: Traditional state-of-the-art models (like FLIM or RLOCATOR) see performance drops ranging from 9% to 194% when moving from stationary to non-stationary real-world data.
  • The Power of Hybrid Rewards: While deep embeddings (via CodeBERT) capture semantic meaning well, combining them with classic software engineering metrics provides vital context. Injecting a bug-probability indicator into the DRL reward function boosted localization performance by up to 51%.
  • Mitigating Catastrophic Forgetting: The CL agents successfully balanced plasticity (learning new code changes) and stability (retaining old localization skills), proving that models don't need to sacrifice past knowledge to adapt to the future.

Key Results

When evaluated in realistic, non-stationary settings, the CL techniques dramatically outperformed traditional DL baselines:

  • Accuracy Boosts: CL methods improved Mean Reciprocal Rank (MRR) by up to 61%, Mean Average Precision (MAP) by 44%, and Top@1 accuracy by a staggering 83%.
  • Fine-Grained Localization: At the hunk level (specific code snippets), CL agents outperformed baselines by up to 67% in ranking relevant code for top@5 and top@10 metrics.
  • Massive Speedups: Because CL avoids retraining from scratch, the proposed framework required up to 5x less computational effort (training hours) than the baseline models across almost all studied projects.

Limitations and Future Work

While promising, the authors note a few limitations:

  • Language Specificity: The evaluation was restricted to Java projects. Future work must validate if these findings hold true for other languages like Python or C++.
  • Hyperparameter Tuning: The CL components (CLEAR and EWC) were run using default configurations. Utilizing automated tuning frameworks like Optuna could optimize performance further.
  • Commit-Level Granularity: The current model ranks individual files and hunks. Expanding the framework to select and rank entire multi-file commits is a logical next step.
  • Broader SE Applications: The authors suggest that this CL approach could be highly effective for other software engineering tasks plagued by concept drift, such as just-in-time defect prediction and test case prioritization.

Summary updated

BibTeX
@misc{mindom2024continuously,
  author = {Paulina Stevia Nouwou Mindom and Leuson Da Silva and Amin Nikanjam and Foutse Khomh},
  title = {{Continuously Learning Bug Locations}},
  year = {2024},
  eprint = {2412.11289},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2412.11289},
}
Figure