Getafix: How Facebook tools learn to fix bugs automatically

Facebook has built a tool called Getafix that automatically finds fixes for bugs and offers them to engineers to approve. This allows engineers to work more effectively, and it promotes better over…

Satish Chandra
14 min readintermediate
--
View Original

Overview

The article discusses Getafix, a tool developed by Facebook that automatically identifies and suggests fixes for bugs in code, enhancing engineering efficiency and code quality. It highlights how Getafix learns from past code changes, utilizes advanced clustering algorithms, and integrates with other Facebook tools like Infer and SapFix to improve software stability.

What You'll Learn

1

How to implement Getafix to automate bug fixes in your codebase

2

Why hierarchical clustering improves bug-fixing suggestions

3

When to use Getafix alongside Infer and SapFix for optimal results

Key Questions Answered

How does Getafix learn to suggest bug fixes?
Getafix learns to suggest bug fixes by analyzing patterns from past code changes made by engineers. It employs a hierarchical clustering algorithm to identify and generalize these patterns, allowing it to recommend contextually appropriate fixes for new bugs.
What tools does Getafix integrate with at Facebook?
Getafix integrates with Infer, a static analysis tool that identifies bugs, and SapFix, which suggests fixes for issues detected by the Sapienz testing tool. This integration helps improve the overall stability and performance of Facebook's applications.
What is the impact of Getafix on bug fixing at Facebook?
Getafix has significantly improved the bug-fixing process at Facebook, automatically suggesting fixes for about 60% of null method call issues. It has successfully patched approximately 1,077 null method call bugs, demonstrating its effectiveness in enhancing code quality.
How does Getafix differ from traditional auto-fix tools?
Unlike traditional auto-fix tools that handle basic issues, Getafix can remediate context-dependent problems by learning from complex patterns in code changes. This allows it to provide more nuanced and appropriate fixes tailored to specific situations.

Key Statistics & Figures

Percentage of null method call bugs successfully patched
53 percent
Getafix was able to automatically patch 1,077 out of approximately 2,000 null method call issues.
Percentage of Getafix attempts that passed automatic validation
90 percent
This indicates the reliability of the patches suggested by Getafix.
Percentage increase in fix rate for return not nullable bugs
6 percent
The fix rate increased from 56 percent to 62 percent after suggesting auto-fixes.

Technologies & Tools

Tool
Getafix
Automates the process of finding and suggesting fixes for bugs in code.
Tool
Infer
Static analysis tool used to identify bugs such as null pointer exceptions.
Tool
Sapfix
Suggests fixes for bugs detected by the Sapienz testing tool.
Tool
Sapienz
Intelligent automated testing system for Facebook's applications.

Key Actionable Insights

1
Implement Getafix in your development workflow to automate routine bug fixes, allowing engineers to focus on more complex issues.
By integrating Getafix, teams can enhance their productivity and maintain higher code quality, as the tool learns from past fixes and suggests relevant solutions.
2
Utilize the hierarchical clustering technique employed by Getafix to analyze your codebase for common bug patterns.
This approach can help identify recurring issues and streamline the debugging process, making it easier to maintain code quality.
3
Leverage Getafix's integration with Infer and SapFix to create a robust bug-fixing ecosystem within your applications.
This synergy allows for comprehensive testing and fixing of bugs, ultimately leading to more stable software.

Common Pitfalls

1
Relying solely on traditional auto-fix tools can lead to missed context-dependent fixes.
Many traditional tools are limited to basic issues and do not account for the specific context of code changes, which can result in inadequate or incorrect fixes.