Branching in a Sapling Monorepo
Meta's Sapling monorepo handles branching with two workflows: non-mergeable full-repo branching via sl bookmark for short-lived release branches, and mergeable directory branching via sl subtree for long-lived variants. Full-repo merges create multi-parent commits that slow sl log and sl blame for everyone. Directory branching instead records copy and merge metadata in linear commits, so Sapling can run scoped three-way merges between directories while the commit graph stays linear. Teams adopt it when CI is expensive, for long-running experimental work, and to unblock Git migrations. Buck2 config modifiers select which branch a build uses, and the main downside is duplicate code-search hits.
Related posts
- Sapling: Source control that’s user-friendly and scalable
Meta Engineering easyNoviceMeta has open-sourced the client for Sapling, a Git-compatible source control system built over 10 years that scales to repositories with tens of millions of files, commits and branches. Its UX centers on smartlog (a filtered view of your relevant commits), extensive undo/recovery commands, and first-class commit stacks backed by tracked mutation history, plus ReviewStack, a demo UI for reviewing GitHub PRs commit by commit. For scale, Segmented Changelog downloads only the commit graph's shape and lazily fetches data, answering ancestry queries in O(number-of-merges) and file history in O(log n). Sparse profiles committed to the repo, Watchman integration, and a forthcoming virtual file system and Rust server handle the working copy.
- Redesigning source control at Anthropic
Anthropic Engineering mediumAdeptAnthropic replaced git with Scion, an in-house centralized version control system, after its monorepo grew past what git mirrors could serve. Merges went from about 2,500 to over 30,000 per day, main-branch history approached 100 GB, and CI ran around 25 million checkouts a day. Scion assumes clients are always online and keeps commits, merges, blame and history on a horizontally scalable server backed by Spanner. Changesets live in a write-ahead log with recursively computed derived data, and clients fetch content-addressed trees and blobs through tiered caches. The result is a footprint 200x smaller than the old git mirrors, checkouts measured in seconds instead of minutes, and a 25% CI CPU saving, built by a team of seven in five months with heavy Claude assistance.
- Build faster with Buck2: Our open source build system
Meta Engineering mediumAdeptBuck2 is Meta's from-scratch rewrite of Buck, open sourced with a Rust core and all language rules written in Starlark, and it completes builds about twice as fast as Buck1 internally. Its speed comes from a single incremental dependency graph held by a persistent daemon instead of separate target/action graph phases, plus Bazel-compatible remote execution and integration with virtual file systems via Watchman and Sapling. New rule primitives make complex patterns safe and efficient: dynamic_output lets rules run tools like ocamldep and wire dependencies from their output, and transitive-sets (tsets) avoid O(n²) memory for C++ link closures. The open source release is nearly identical to Meta's internal version and is aimed mainly at moderately sized multi-language projects.
- Shopify-Made Patterns in Our Rails Apps
Shopify Engineering easyNoviceShopify's Rails monolith relies on a set of in-house patterns: the dev CLI for consistent environment setup, a podded architecture that shards the full infrastructure stack by shop, and domain-driven components that share a single database with no database-level foreign keys. Migrations are periodically squashed into structure.sql, and quality is kept up as the org grows through a git-based translation platform, an open-source maintenance tasks engine built on Active Job, and Monorail, which enforces versioned Kafka event schemas with PII annotations. It is pitched as an onboarding overview for new Shopify developers rather than a detailed implementation guide.
- How We’re Building Git for Infrastructure
Railway mediumAdeptRailway's Changesets let teams fork an infrastructure environment like a Git branch, record each config or service change as a changeset, and merge it back into the parent environment. Instead of storing Git-style parent pointers (too many sequential queries) or rebuilding the tree in memory (too memory-heavy), each changeset has a single original environment and an ordering id from a PostgreSQL serial column, and each environment records its parent and fork point, so a diff is one simple query. The scope was deliberately limited to fork-and-merge-into-parent, with no arbitrary environment merges or merge requests. Tests use a Mermaid gitGraph-like DSL helper that can also print a Mermaid diagram of the test state for visual debugging.