---
title: "Speeding up C++ build times"
description: "Figma halved C++ build times by attacking the volume of preprocessed bytes sent to the compiler, which had grown far faster than the codebase."
url: "https://swe.quest/articles/speeding-up-c-build-times-74d542dbb5ae649d"
canonical: "https://www.figma.com/blog/speeding-up-build-times/"
source: "Figma"
published: "2024-04-25"
difficulty: "medium"
kind: "Case study"
reading_minutes: 8
tags: ["build-systems","c-cpp","developer-productivity","static-analysis","ci-cd"]
---

# Speeding up C++ build times

A post on [Figma](https://swe.quest/sources/figma.md), published 2024-04-25, 8 min read, Case study. Original: [https://www.figma.com/blog/speeding-up-build-times/](https://www.figma.com/blog/speeding-up-build-times/)

## Summary

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.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Build systems](https://swe.quest/tags/build-systems.md) (Engineering practices)
- [C & C++](https://swe.quest/tags/c-cpp.md) (Languages)
- [Developer productivity](https://swe.quest/tags/developer-productivity.md) (Engineering practices)
- [Static analysis](https://swe.quest/tags/static-analysis.md) (Engineering practices)
- [CI/CD](https://swe.quest/tags/ci-cd.md) (Reliability & operations)

## Prerequisites

- C++ header includes ([easy posts on C & C++](https://swe.quest/tags/c-cpp.md?difficulty=easy))
- C++ compilation model ([easy posts on C & C++](https://swe.quest/tags/c-cpp.md?difficulty=easy))
- forward declarations

## Keywords

DIWYDU, includes.py, Include What You Use, libclang, Bazel, Fwd.h, Clang AST

## Related posts

- [Large-scale distributed builds with Microsoft Build Accelerator](https://swe.quest/articles/large-scale-distributed-builds-with-microsoft-build-accelerator-9baa9a7436e8437c.md): Engineering@Microsoft · 2021-08-18 · Easy · 4 min read · Build systems, Developer productivity, Caching
  Microsoft's BuildXL distributes and caches builds for its largest codebases.
- [How to use Rust in ClickHouse: avoiding a full rewrite](https://swe.quest/articles/how-to-use-rust-in-clickhouse-avoiding-a-full-rewrite-e470754e07a213d4.md): ClickHouse · 2025-12-17 · Medium · 13 min read · Rust, C & C++, Build systems, Refactoring & migrations, Testing
  ClickHouse, a 1.5M-line C++ analytic database, is adopting Rust incrementally rather than rewriting.
- [Improving machine learning iteration speed with faster application build and packaging](https://swe.quest/articles/improving-machine-learning-iteration-speed-with-faster-application-build-and-76fe5935fe0be272.md): Meta Engineering · 2024-01-29 · Medium · 5 min read · Build systems, Developer productivity, ML platforms, Storage systems, Python
  Meta 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).
- [Copy-on-Write performance and debugging](https://swe.quest/articles/copy-on-write-performance-and-debugging-d6fa950b2bebd0f3.md): Engineering@Microsoft · 2024-05-14 · Medium · 5 min read · Build systems, Storage systems, Performance engineering, .NET, Developer productivity
  Testing 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.
- [Build better software to build software better](https://swe.quest/articles/build-better-software-to-build-software-better-5c6078f2e1d6c4da.md): Slack Engineering · 2025-11-06 · Medium · 17 min read · Build systems, Developer productivity, CI/CD, Refactoring & migrations, Caching
  Slack 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.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
