Home›AI Tools›How GitHub Copilot Handles Million-Line Pull Requests
AI Tools

How GitHub Copilot Handles Million-Line Pull Requests

GitHub Copilot has rebuilt its pull request diff surface to handle massive code changes with hundreds of inline comments—enabling smooth, real-time reviews even for extremely large codebases.

GitHub Copilot app displaying a large pull request with over a million lines of code and hundreds of inline comments, rendered smoothly with responsive scrolling and expandable sections

Large software refactors and system migrations often require a single, sweeping change that cannot be split into smaller pull requests. These changes grow into massive pull requests—sometimes with over a million lines of code and hundreds of inline review comments—making them difficult to review effectively.

In a recent technical deep dive, GitHub Copilot engineers describe how they redesigned the pull request view in the GitHub Copilot app to maintain performance and usability even when dealing with such extreme scale. The goal was not just to render large diffs, but to preserve a smooth, responsive user experience that feels natural despite the complexity of the content.

What Happened: A Real-World Test of Performance

The team tested their new diff rendering system by opening an open-source pull request with 2,200 files, over a million changed lines, and more than 400 inline review comments. This was the largest pull request they could find in their dataset, representing a real-world scenario where developers face the full weight of a massive code change.

What they discovered was that traditional diff rendering—built around virtualization and known row heights—fails when comments are introduced. Comments have variable heights due to markdown wrapping, expandable sections, reply composers, and image loading. These elements don’t have fixed dimensions and can change dynamically during use, breaking the assumption that all heights are known before rendering.

Key Facts and Technical Breakthroughs

  • The original design relied on a ‘all heights known before paint’ contract, which works well for pure code diffs but fails when comments are included.
  • Comments introduce dynamic content whose height depends on real-time rendering, user interaction, and asynchronous assets.
  • Instead of one shared geometry for code and comments, the team split the document into two independent domains: a deterministic code geometry and a dynamic block geometry for comments.
  • Each comment block is identified by stable keys (file, line, side), not by pixel position, allowing it to survive reflows and content changes.
  • Block heights are measured lazily and cached with fingerprints (content, open state, width) to avoid re-measuring on every resize.
  • A measurement scheduler avoids using per-block ResizeObservers, which could cause cascading reflows and performance degradation.

The new architecture ensures that only a small number of comment blocks are measured at any time—typically a few thousand—while preserving the illusion of a full, responsive diff surface. The code geometry remains unchanged and independent, so scrolling, row navigation, and scrollbar positioning remain accurate and stable.

How It Works: The Architecture Behind the Experience

Traditional virtualized diff surfaces work by mounting only the rows visible on screen and recycling DOM elements as users scroll. This works well when every row is a line of code with a known height. But comments introduce variability.

GitHub Copilot’s solution splits the diff into two geometries:

  1. Code geometry: A deterministic, prefix-summed table of line heights. This remains fixed and is never rebuilt when comments change.
  2. Dynamic block geometry: A separate index for comment blocks. Each block has a stable key (file, line, side) and tracks its content, expansion state, and width. Heights are measured only when needed and cached when the fingerprint and width remain unchanged.

When a user scrolls or expands a comment, only the relevant blocks are re-measured. The rest of the layout remains stable. This prevents scroll jumps and maintains a consistent user experience.

The team also implemented a measurement scheduler that avoids per-block ResizeObservers. These would trigger reflows and create performance bottlenecks. Instead, they use a batched, prioritized measurement system that only activates when necessary and respects the user’s current view.

Integrated circuit on microchip.jpg
Integrated circuit on microchip.jpg by Wikimedia Commons contributor, Public domain, via Wikimedia Commons. · Source

Why It Matters: A Better Developer Experience

For developers, reviewing a large pull request used to mean either waiting for it to load or abandoning it entirely. The new system changes that dynamic.

Now, a million-line diff with hundreds of threaded comments opens and behaves like a normal-sized pull request. Users can:

  • Scroll smoothly without jumps or lag.
  • Expand or collapse sections without shifting surrounding code.
  • Return to a previous point in the review without losing context.
  • See full comment content instead of clipped or scrollable boxes.

This is not just a technical achievement—it’s a shift in how developers interact with code. A pull request is no longer a static document. It’s a living conversation that evolves during review, and the interface must adapt to that reality.

Limitations and Open Questions

While the new system performs well under typical use, it still has limits:

  • It assumes a reasonable number of comment blocks—thousands is manageable, but tens of thousands may still cause performance issues.
  • It relies on stable keys and fingerprints, which may not work in edge cases where content changes rapidly or metadata is inconsistent.
  • Performance under extreme load (e.g., very large files, many nested replies) has not been fully tested.
  • It doesn’t address the broader issue of how to split large changes into smaller, reviewable pieces—only how to render them once they exist.

These limitations suggest that while the rendering experience is now robust, the root problem—how to manage large-scale refactors—still requires better engineering practices and tooling.

What to Watch Next

As AI-powered code review tools grow in sophistication, the ability to handle large, complex code changes will become even more critical. GitHub Copilot’s new architecture sets a benchmark for how to render dynamic, evolving content in developer tools.

Developers and engineers should watch for further updates on how AI tools manage large-scale refactors, especially in relation to pull request workflows. For example, OpenAI’s GPT-6 Sol and Luna may offer similar capabilities for code analysis and suggestion in large codebases. Meanwhile, stacked pull requests remain a key strategy for breaking down large changes into manageable pieces.

As AI tools evolve, the balance between powerful, comprehensive analysis and maintainable, readable interfaces will continue to be a central challenge in software development.

Original source: GitHub Blog

Sources & further reading

Featured image: Green Datacenter AG – Industriestrasse 31 by Ralph Plennert, CC BY-SA 4.0, via Wikimedia Commons. Image source · License

SIRIUSITY BRIEFS

Get the latest from Siriusity Journal

AI, science, technology and future-tech updates delivered to your inbox.

We use your email only for these briefs. Double opt-in is required.