Build faster with Buck2: Our open source build system
Buck2 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.
Related posts
- 5 Things you didn’t know about Buck2
Meta Engineering easyNoviceBuck2, Meta's open-source successor to the Buck build system, completes builds roughly 2x faster than Buck1 in internal tests. Its core is written in Rust, chosen over Java, Haskell and Go for performance, memory control without GC over large graphs, and safe concurrency, while rules are written in Starlark. With remote execution it can skip downloading intermediate outputs by tracking only their hashes. It uses 11 distinct path types for type safety, keeps all language knowledge out of the core in a replaceable Starlark prelude, and offers BXL for querying the build graph and defining new actions, for example to generate IDE projects.
- Improving machine learning iteration speed with faster application build and packaging
Meta Engineering mediumAdeptMeta cut ML engineers' build and packaging overhead by double-digit percentages by tackling build non-determinism, pruning dependencies, and replacing monolithic XAR executables with an incremental Content Addressable Filesystem (CAF). Non-determinism from compilers and build rules is mitigated inside the Remote Execution service that Buck2 sends nearly all build actions to, so stable warm revisions can reuse cached outputs. CAF describes each executable as a flat manifest of content digests, skips uploads already in CAS, and fetches only missing content via per-host CAS daemons that share data peer-to-peer over Owl. Btrfs compression and copy-on-write keep on-disk size close to XAR while sharing files across executables. Planned next steps are lazy on-demand fetching (LazyCAF) and putting all ML engineers on uniform revisions to raise cache hit rates.
- Build better software to build software better
Slack Engineering mediumAdeptSlack cut the 60-minute build pipeline for Quip and Slack Canvas's backend by applying classic software engineering principles (hermetic, idempotent, granular units of work and clean separation of concerns) before adopting Bazel. A dependency edge from the built Python backend into the TypeScript frontend build zeroed the cache hit rate and cost about 35 minutes per build. The team untangled build code from application code, rewrote orchestration in Starlark, cut Python build scripts down to the standard library only, and used a Rust diffing tool to verify the new artifacts matched the old ones. The core lesson is that Bazel's caching and parallelism only pay off once the build graph is acyclic, well-defined and finely granular.
- Enabling Kotlin incremental compilation on Buck2
Meta Engineering mediumAdeptMeta integrated the Kotlin incremental compiler into Buck2 via Kotlin's experimental Build Tools API, making some large Android modules build up to 3x faster and improving incremental build times about 30% for the average developer. The work involved migrating the toolchain to the shaded kotlin-compiler-embeddable, using Buck2 incremental actions to keep prior outputs and compute changed-file lists from input hashes, making the cache relocatable for remote execution, and generating classpath snapshots as a separate cacheable action. Custom compiler plugins had to be made incremental and accumulate results across multiple compilation rounds. jvm-abi-gen still lacks incremental support, so a stopgap merges the new ABI with the previous output.
- Bun v1.1.39
Bun mediumAdept
Bun v1.1.39 introduces bun.lock, a human-readable text lockfile that improves git diffs and works with tools like Dependabot and Renovate, and makes cached bun install 30% faster. It adds streaming fetch() request bodies (chunked transfer encoding, or Content-Length when the size is known) and a zero-copy native onBeforeParse plugin API for Bun.build(), written in Rust via napi.rs, that runs in Bun's threadpool. Other changes include inline snapshot tests in bun:test, heap snapshots that count native memory, a 15% peak-RSS reduction for churned WebSocket server connections, full Node test-suite parity for string_decoder, punycode and querystring, and a WebKit upgrade bringing Error.isError and a 44% faster String.prototype.at.