Industry Insights 12 min read

Why Did Facebook Choose Mercurial Over Git? A Deep Dive into Performance and Culture

Greg Foster investigates why Facebook abandoned Git for Mercurial, revealing that massive repository size caused severe performance bottlenecks, Git’s inability to scale, and the collaborative culture of Mercurial’s maintainers, ultimately shaping Facebook’s tooling decisions and influencing broader industry practices.

Architect
Architect
Architect
Why Did Facebook Choose Mercurial Over Git? A Deep Dive into Performance and Culture

Background

Facebook initially adopted Git around 2004. By 2012 the monolithic codebase had grown to many times the size of the Linux kernel (the kernel has ~17 million lines of code and ~44 000 files). The scale caused severe performance degradation in basic Git operations.

Performance Bottlenecks

The primary issue was the stat‑ing of every file on each command. As the file count increased, Git’s filesystem checks became a linear bottleneck. Simulated repositories matching Facebook’s projected growth showed that common Git commands could take more than 45 minutes to complete.

Interaction with Git Maintainers

Facebook contacted the Git maintainers for performance improvements. The maintainers responded by recommending repository splitting into multiple smaller .git repositories, a strategy Facebook deemed infeasible for their monorepo. No concrete performance patches were offered.

https://engineering.fb.com/2014/01/07/core-infra/scaling-mercurial-at-facebook/

Alternative Solutions Considered

Perforce – raised concerns about local consistency and lacked clear remediation from the vendor.

BitKeeper – evaluated but quickly dismissed.

Mercurial – offered comparable raw performance to Git, but its codebase is written in Python with a clean object‑oriented design, making it easier to extend.

Migration Process

After a Mercurial hackathon in Amsterdam, Facebook committed to migration. The engineering effort included:

Mapping frequently used Git commands to Mercurial equivalents.

Collecting usage statistics of Git commands across the organization.

Developing internal tooling to support “stacked diffs,” a workflow that later influenced GitHub’s review system.

Providing a forum for engineers to raise concerns and discuss edge cases, which resulted in minimal resistance.

The migration was rolled out gradually, with extensive documentation and training to ensure a smooth transition for all teams.

Technical Outcomes

Facebook contributed performance patches to Mercurial, improving its handling of very large repositories.

Extensions to Phabricator were added to support Mercurial workflows.

The “stacked diffs” concept enabled parallel code review and was later adopted by other platforms.

Lessons Learned

The decision to adopt Mercurial was driven less by raw performance superiority and more by the openness and responsiveness of the Mercurial maintainers. Collaborative engagement allowed Facebook to influence the VCS’s evolution, which was critical for long‑term maintainability of their monorepo.

Conclusion

Facebook’s shift from Git to Mercurial illustrates how large‑scale engineering constraints can shape tooling choices, and how active community support can be a decisive factor when existing tools struggle to scale.

Code example

相关阅读:
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

performanceGitVersion ControlFacebookEngineering CultureMercurial
Architect
Written by

Architect

Professional architect sharing high‑quality architecture insights. Topics include high‑availability, high‑performance, high‑stability architectures, big data, machine learning, Java, system and distributed architecture, AI, and practical large‑scale architecture case studies. Open to ideas‑driven architects who enjoy sharing and learning.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.