Speeding up C++ build times
Figma halved C++ build times by attacking the volume of preprocessed bytes sent to the compiler, which had grown far faster than the codebase. Manually pruning unnecessary includes in the largest files cut compiled bytes 31% and cold builds 25%, motivating two automated tools: DIWYDU, a libclang-Python AST checker that flags headers a file doesn't directly use, and includes.py, a fast Clang-free script that estimates transitive bytes per source file and warns on PRs that regress it. Per-directory Fwd.h files centralize forward declarations so headers avoid heavy includes, and Bazel remote caching shaved over two minutes off local builds; together the tools catch 50-100 potential slowdowns daily.
Related posts
- Large-scale distributed builds with Microsoft Build Accelerator
Engineering@Microsoft easyNoviceMicrosoft's BuildXL distributes and caches builds for its largest codebases. Runtime file access monitoring fails the build whenever a process reads unpredicted inputs or writes conflicting outputs, which makes incremental builds trustworthy enough to ship from. Its key caching change is a two-phase cache lookup: the fingerprint combines statically predicted inputs with dynamically observed ones, such as the subset of headers a C++ compiler actually reads. This avoids both over-approximated inputs and hand-maintained dependency annotations. Together with CloudBuild, it cut builds that took over 24 hours down to minutes, at the scale of millions of process invocations.
- How to use Rust in ClickHouse: avoiding a full rewrite
ClickHouse mediumAdept
ClickHouse, a 1.5M-line C++ analytic database, is adopting Rust incrementally rather than rewriting. It started with Corrosion to wire Rust into CMake and a BLAKE3 hash function, then took on a client history-navigation feature, the PRQL query language, and Databricks' delta-kernel-rs for Delta Lake support. The integration problems were mostly practical: hermetic reproducible builds with vendored crates, buggy FFI wrappers caught quickly by existing CI and fuzzing, library panics that crash the server, compiling Rust with sanitizers (now easier with an MSan toolchain), duplicated cross-compilation setup, and transitive dependencies linking system OpenSSL.
- 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.
- Copy-on-Write performance and debugging
Engineering@Microsoft mediumAdeptTesting Dev Drive with copy-on-write (block clone) linking across large internal Microsoft repos showed build-time reductions up to 43%, with many repos gaining 10% or more. C# repos with deep project-to-project dependencies and builds that copy files into microservice layouts benefited most, while C++-heavy repos and builds ending in long linear dependency chains gained little. Practical tips cover spotting CoW links with fsutil queryExtentsAndRefCounts, allowing ProcMon and Xperf filter drivers on Dev Drive, and using refsutil leak to clean up orphaned references that hit ReFS's 8176-clone-per-block limit. CoW becomes automatic in Windows 11 24H2 and Server 2025; until then, add the CopyOnWrite SDK to MSBuild repos.
- 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.