Get AI summaries of any video or article — Sign up free
Why Facebook Doesn't Use Git thumbnail

Why Facebook Doesn't Use Git

The PrimeTime·
5 min read

Based on The PrimeTime's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

Git performance degraded at Facebook’s monorepo scale, with the cost tied to Git examining/statting large numbers of files.

Briefing

Facebook’s shift away from Git and toward Mercurial (and then custom tooling built on top of it) came down to one practical bottleneck: Git’s performance degraded as the company’s monorepo grew to massive scale. Around 2012, engineers began feeling Git operations slow down—not always catastrophically, but enough to justify a serious investigation. The key pain point wasn’t just “cloning feels slow”; it was the cost of Git examining (statting) huge numbers of files, with latency compounding as file counts rose.

A 2014 Facebook blog post (and later follow-ups) described Git’s scaling limits in terms of repository size. The company’s codebase was projected to grow far beyond what Git could handle comfortably. In a simulation meant to match expected growth, basic Git commands reportedly took over 45 minutes to complete. The prospect of waiting for “engineers are complaining” before fixing the problem was unacceptable; by the time that happened, the repository would be too unwieldy to rescue. The team concluded that damage control would be Herculean, so they pursued a cleaner solution early.

Before committing to Mercurial, the investigation explored alternatives. Perforce was considered, but an architectural flaw around local consistency between readers and writers undermined confidence. Other systems like BitKeeper were also evaluated and quickly ruled out. Mercurial emerged as the leading candidate because it offered performance comparable to Git while being architecturally simpler—implemented in Python with object-oriented patterns and designed to be extensible. That extensibility mattered: the team wanted a version control system that could be shaped to their needs rather than forcing their workflow to fit a tool that couldn’t scale.

The next phase focused on feasibility and adoption. Engineers attended a Mercurial hackathon in Amsterdam to validate that the Mercurial community was welcoming and that maintainers would support aggressive changes. Once convinced, the migration required winning over the rest of the organization—an inherently political and emotional process for developers whose daily workflows depend on tooling. The rollout avoided flame wars by mapping common Git commands and workflows to Mercurial equivalents, measuring which Git operations were used most, and creating channels for developers to raise edge cases.

After the company cut over to Mercurial, Facebook contributed performance improvements back to the project, helping make it a better fit for large monorepos. It also extended Fabricator to support Mercurial-style “diffs,” enabling “stacked changes” that unlock smoother code review and parallelization—changes that later influenced tools like Graphite. The broader takeaway from the accounts is that major engineering tool decisions are often driven by human factors—who is willing to collaborate, how migrations are socialized, and whether teams can translate workflow pain into a workable technical plan—more than by abstract technology comparisons alone.

Cornell Notes

Facebook’s move away from Git was driven by scaling pain: as the monorepo grew, Git operations slowed, largely because Git had to examine (stat) every file and the cost compounded with file count. Engineers projected that continued growth would make basic commands take unacceptably long, so they sought a system that could handle large monorepos without waiting for widespread complaints. After evaluating Perforce and other options, Mercurial won out for performance and for being extensible enough to support custom workflow needs. The migration succeeded not only through technical work, but through careful internal change management—mapping workflows, measuring command usage, and addressing developer concerns. The result included performance improvements to Mercurial and tooling built around stacked diffs for better code review and parallel development.

What specific Git scaling issue pushed Facebook to investigate alternatives?

The central problem was performance degradation as repository size and file counts grew. Git operations became slow enough to warrant investigation, with the bottleneck described as Git statting/examining every file it touches—so latency increased as the number of files increased. In a simulation matching expected scale, basic Git commands reportedly took over 45 minutes to complete, making continued growth untenable.

Why didn’t simply “split the repo” solve the problem?

Sharding the monorepo was treated as a non-starter for Facebook’s engineering needs. The investigation also found that Git maintainers’ suggested path—splitting into smaller repos—wasn’t workable in practice. The team needed a solution that preserved the monorepo workflow while addressing performance at scale.

Which alternatives were considered before Mercurial, and what disqualified them?

Perforce was considered early, but Facebook pointed to an architectural flaw involving local consistency between reader and writer components, and the sales team lacked confidence-building road map plans to fix it. BitKeeper and other options were also evaluated but were quickly disqualified, leaving Mercurial as the remaining strong candidate.

What made Mercurial attractive beyond raw performance?

Mercurial was seen as both performant and more extensible due to its cleaner architecture and implementation approach (Python with object-oriented patterns). That extensibility mattered because Facebook wanted to extend the system and build workflow features on top of it, rather than being constrained by Git’s structure.

How did Facebook reduce resistance during the Git-to-Mercurial migration?

The migration effort emphasized adoption engineering: months of socializing the change, mapping common Git commands and workflows to Mercurial equivalents, and measuring the frequency of Git commands used across the company. It also created opportunities for developers to raise concerns and discuss edge cases, aiming to prevent defensive reactions and flame wars.

What workflow capability became a lasting advantage after the migration?

Facebook leveraged Mercurial concepts of diffs and extended Fabricator to support stacked changes. “Stack diffs” enabled developers to keep working on top of earlier changes while code review proceeded, improving parallelization and reducing review bottlenecks. That stacked-review workflow later influenced tools such as Graphite.

Review Questions

  1. What performance mechanism in Git became problematic as repository file counts increased, and how did that shape the decision timeline?
  2. Why was sharding rejected, and what alternative path did the team pursue instead?
  3. What combination of technical work and internal change management helped the migration avoid widespread developer backlash?

Key Points

  1. 1

    Git performance degraded at Facebook’s monorepo scale, with the cost tied to Git examining/statting large numbers of files.

  2. 2

    Projected growth made “wait until engineers complain” unacceptable, since the repository would become too unwieldy to fix later.

  3. 3

    Perforce was evaluated but undermined by an architectural local-consistency flaw and a lack of credible roadmap to address it.

  4. 4

    Mercurial was chosen for comparable performance and for extensibility that allowed Facebook to shape the system and workflows.

  5. 5

    The migration succeeded through adoption planning: mapping workflows, measuring command usage, and creating structured feedback channels for edge cases.

  6. 6

    After switching, Facebook contributed performance improvements back to Mercurial and built tooling around stacked diffs to improve code review and parallel development.

Highlights

The decisive scaling pain wasn’t just “slow clones,” but Git’s file-by-file examination cost that worsened as file counts exploded.
A simulation matching expected growth reportedly produced basic Git commands taking over 45 minutes—enough to force an early, proactive change.
The migration wasn’t only a tool swap; it included months of workflow mapping and command-frequency analysis to reduce developer resistance.
Stacked diffs became a durable workflow win, enabling parallel work while reviews progressed.

Topics

  • Git Scaling
  • Mercurial Migration
  • Monorepo Performance
  • Stacked Diffs
  • Dev Tools Adoption

Mentioned