Neural Code Generation Model for Performance Bug Repair

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Performance bugs in source code are difficult to detect and fix due to their subtle nature, which does not typically cause system failures, and existing technologies lack efficient methods for generating repair code without extensive fine-tuning.

Innovation Solution

A pre-trained neural code generation model is used to generate repair code for performance bugs, guided by a code transformation instruction derived from historical patterns of source code fixes. This approach avoids the need for fine-tuning and allows for the generation of repair code based on abstract bug patterns.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Loss of time

If a pre-trained neural code generation model is used without fine-tuning, then computational resources and time are saved, but the model's ability to generate accurate repair code for performance bugs is insufficient

Engineering Contradiction:
Improvefine-tuning timeVSAvoidrepair code accuracy
Core Design Contradiction:
Loss of timeVSManufacturing precision

Solution Approach 1:

The system performs preliminary actions by constructing a prompt that includes the buggy code, abstract bug pattern, and code transformation instruction before passing it to the pre-trained model. This preparation work enables the model to generate accurate repair code without requiring fine-tuning, thus saving time while maintaining precision.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The patent introduces an intermediary mechanism - the prompt construction module that translates the bug detection results and historical fix patterns into a structured instruction format. This intermediary bridges the gap between the pre-trained model's general capabilities and the specific requirements of performance bug repair, enabling accurate code generation without fine-tuning.

Inventive Principle:
Principle #24Intermediary (Mediator)

2Manufacturing precision

If extensive fine-tuning is performed on the neural model for repair code generation, then repair code accuracy improves, but computational burden and training time increase significantly

Engineering Contradiction:
Improverepair code accuracyVSAvoidcomputational burden
Core Design Contradiction:
Manufacturing precisionVSUse of energy by moving object

Solution Approach 1:

The system extracts only the essential elements needed for repair code generation - the abstract bug pattern and code transformation instruction - from historical fix data. By taking out only the necessary information and embedding it in the prompt, the system achieves accurate repair code generation without the computational burden of fine-tuning the entire model.

Inventive Principle:
Principle #2Taking out (Extraction)

Solution Approach 2:

The system performs preliminary processing of historical fix data to create reusable code transformation instructions that can be directly applied to new bugs. This preliminary action eliminates the need for extensive fine-tuning by preparing the knowledge in advance in a format that the pre-trained model can directly utilize.

Inventive Principle:
Principle #10Preliminary action

3Adaptability or versatility

If the system uses abstract bug patterns derived from historical fixes, then generalization capability improves, but the complexity of pattern matching and retrieval increases

Engineering Contradiction:
Improvegeneralization capabilityVSAvoidpattern matching complexity
Core Design Contradiction:
Adaptability or versatilityVSDevice complexity

Solution Approach 1:

The system applies local quality by focusing the pattern matching process on specific local features of the bug - the abstract bug pattern that captures the essential structure of the performance issue. Instead of comparing entire codebases, the system locally identifies and matches bug patterns, reducing complexity while maintaining generalization capability.

Inventive Principle:
Principle #3Local quality

Data Source

PatentUS12242372B2Performance bug repair via retrieval-augmented neural code generation model
Publication Date: 2025.03.04 MICROSOFT TECHNOLOGY LICENSING LLC
  • US12242372B2 patent drawing
  • US12242372B2 patent drawing
  • US12242372B2 patent drawing

AI summary

A pre-trained neural code generation model generates repair code for a method containing a performance bug given a prompt including a code transformation instruction. The code transformation instruction guides the model on how to predict the repair code when the model has not been fine-tuned for the repair code task. The code transformation instruction is retrieved from abstract bug patterns derived from historical performance bug fixes found in commits to a source code repository. The augmentation of the code transformation instruction in the prompt to the pre-trained neural code generation model provides the model with a hint on how the repair code may be generated based on similar performance bug fixes.