Meta Open-Sources Buck2: A Rust-Powered Build System That Doubles Build Speeds
Share this article
For developers wrestling with sluggish build times, Meta’s newly open-sourced Buck2 promises a paradigm shift. Built from scratch in Rust and designed for extreme parallelism, Buck2 completes builds 2x faster than Buck1 in Meta’s internal benchmarks—handling millions of daily builds across thousands of engineers. Unlike traditional build systems, Buck2 decouples its core engine from language-specific rules, enabling unprecedented flexibility and performance gains.
Why Rebuild the Build System?
Build systems sit at the heart of developer productivity. "Anything we can do to make the experience quicker directly impacts how effective a developer can be," note Meta engineers Chris Hopman and Neil Mitchell. Buck2 preserves Buck1’s conceptual workflow while integrating innovations from Bazel, Adapton, and Shake. Its core principles:
- Language-Agnostic Core: Written in Rust, the core knows nothing about Java, C++, or other languages. All rules (e.g.,
rust_binary,ocaml_library) are defined in Starlark, making them modular and easier to modify. - Single Dependency Graph: Eliminates phased builds (target/action graph separation), reducing bugs and maximizing parallelism.
- Remote Execution & Virtual FS Ready: Integrates seamlessly with tools like Buildbarn and EngFlow for distributed builds, and Sapling for sparse repository checkouts.
The Need for Speed: How Buck2 Delivers
Buck2’s performance stems from architectural rigor:
rust_binary(
name = "my_binary",
srcs = ["main.rs"],
deps = [":my_library"],
)
Example Buck2 target definition—syntax remains familiar to Buck1/Bazel users.
- Near-instant incremental builds: Minimal rebuilds when source files don’t change.
- Superconsole: A redesigned terminal UI (powered by Meta’s open-sourced library) provides real-time feedback.
- Persistent daemon: Maintains a global dependency graph, invalidating only changed components.
Buck2’s animated console output highlights build progress and parallelism.
Empowering Rule Authors
For those writing build rules, Buck2 replaces Buck1’s Java-centric approach with Starlark primitives designed for safety and performance:
- Dynamic Dependency Resolution: Rules like OCaml leverage
dynamic_outputto auto-infer file dependencies viaocamldep. - Transitive Sets (tsets): Efficiently model complex dependencies (e.g., C++ linking) without O(n²) overhead.
"By abstracting features into reusable APIs, we balance expressibility with hermeticity," the team explains. This prevents rule authors from inadvertently breaking critical invariants.
Try It Today
Buck2 is optimized for multi-language projects and is nearly identical to Meta’s internal version—only toolchain and remote-execution endpoints differ. Meta reports engineers produced more code thanks to reduced wait times. The system is available on GitHub, with documentation for getting started.
"We’ve designed Buck2 to be fast. If there’s no work to do, it’s instant. If there is, it parallelizes aggressively." — Meta Engineering
As monolithic build systems hit scalability walls, Buck2’s decoupled, performant architecture offers a compelling path forward. For developers tired of watching progress bars, the wait might finally be over.
Source: Meta Engineering Blog