Web Development

How GitHub Turbocharged Performance for Large Pull Requests

2026-05-07 12:24:20

In this Q&A, we explore how GitHub overhauled the performance of its pull request diff view, especially for large changes spanning millions of lines. Learn about the challenges, the three-pronged strategy, and the measurable impact on responsiveness and memory usage.

1. What specific performance issues did GitHub encounter with large pull requests?

When viewing very large pull requests on GitHub, users experienced severe performance degradations. In extreme cases, the JavaScript heap memory exceeded 1 GB, DOM node counts surpassed 400,000, and page interactions became extremely sluggish or even unusable. Key metrics like Interaction to Next Paint (INP)—a measure of how quickly a page responds to user actions—were far above acceptable thresholds. This meant users could actually feel input lag when scrolling, clicking, or typing. Even though smaller and medium-sized pull requests remained fast, the largest ones brought the browser to its knees, making code review a frustrating experience. These problems stemmed from the sheer volume of diff lines rendered all at once, without any optimization for scale.

How GitHub Turbocharged Performance for Large Pull Requests
Source: github.blog

2. How did GitHub approach solving these performance problems?

GitHub quickly realized there was no single magic bullet. Techniques that preserved every feature and browser-native behavior hit a ceiling at extreme scale. Conversely, mitigations designed only for the worst-case would harm everyday reviews. So the team developed a set of strategies, each targeting a specific pull request size and complexity. They focused on three main themes: focused optimizations for diff-line components to keep medium and large reviews fast without sacrificing native features like find-in-page; graceful degradation with virtualization to maintain usability for the largest PRs by limiting what’s rendered; and foundational improvements in rendering and components that benefit every pull request size. This multi-pronged approach allowed them to address performance holistically without compromising user experience.

3. What are the three key strategies GitHub adopted?

GitHub’s strategy can be broken down into three complementary approaches:

4. How does the focused optimization for diff-line components work?

The first strategy targets the core rendering of diff lines, which is the most common view for pull requests. GitHub engineers carefully profiled the React components that render each line and identified bottlenecks in how diff data was processed, styled, and updated. They then optimized these components to reduce unnecessary re-renders, streamline prop updates, and use more efficient data structures. For example, they minimized the number of DOM nodes created per line and avoided heavy computations during scroll events. The goal was to make the default experience fast for pull requests of medium to large size—those with tens of thousands of lines—without removing any user-facing features. This meant that normal review actions, like scrolling or using find-in-page, remained snappy. These optimizations alone significantly reduced memory usage and INP scores for a broad range of pull requests.

5. What is the graceful degradation approach using virtualization?

For the most extreme pull requests—those with hundreds of thousands of lines or more—even the best line-level optimizations aren’t enough. That’s where virtualization comes in. Instead of rendering every diff line at once, GitHub’s system now renders only the lines that are currently visible in the viewport, plus a small buffer above and below. As the user scrolls, new lines are dynamically added and old ones removed. This technique, known as virtual scrolling, drastically reduces the total number of DOM nodes and JavaScript heap size. In memory-constrained environments, virtualization can drop the DOM node count from over 400,000 to just a few thousand. The trade-off is that some features, like full-text find-in-page across the entire diff, may no longer work natively. But for these very large PRs, the improvement in responsiveness and stability far outweighs the loss of that convenience. It’s a deliberate degradation that keeps the experience usable.

How GitHub Turbocharged Performance for Large Pull Requests
Source: github.blog

6. How do foundational improvements benefit all pull request sizes?

Beyond the two targeted strategies, GitHub invested in foundational changes that improve performance regardless of whether a user is in the optimized or virtualized mode. These include rethinking the rendering framework, adopting more efficient React patterns, and optimizing shared components used throughout the diff view. For example, they refactored how diff data is fetched and cached, reducing redundant network calls. They also improved the memory management of event listeners and subscription patterns, which lowered overhead for every interaction. Because these improvements are at the infrastructure level, they compound across every pull request size—tiny one-line fixes benefit just as much as million-line changes. This holistic investment ensures that even without the other two strategies, the baseline performance is better. Together with the focused and virtualized approaches, they create a scalable system that handles the full spectrum of pull request sizes efficiently.

7. What measurable results did these improvements achieve?

After deploying the optimizations, GitHub saw dramatic improvements in key performance metrics. The JavaScript heap size, which could previously exceed 1 GB for massive pull requests, was significantly reduced. DOM node counts dropped from over 400,000 to manageable levels, and Interaction to Next Paint (INP) scores fell well below acceptable thresholds, meaning users no longer experienced perceptible input lag. The improvements were especially notable on the largest pull requests, where the page had previously been nearly unusable. While the team continues to monitor and refine, the new default experience for the Files changed tab is now fast and responsive for the vast majority of pull requests. These results didn’t come from a single change but from the combined effect of the three strategies: line-level optimizations, virtualization for extreme cases, and foundational improvements that raised the floor for all scenarios.

Explore

Go 1.25 Introduces Flight Recorder: Real-Time Execution Diagnostics for Production Services 10 Lessons in Digital Amiability from the Vienna Circle CISA Warns of Active Attacks Exploiting ConnectWise ScreenConnect and Windows Vulnerabilities Building Your Own Video Game Figure Collection: From Store Shelves to Custom Creations Defending the Software Supply Chain: A Practical Guide to Detecting Watering Hole Attacks with AI-Powered EDR