Reducing C++ Compilation Times Through Good Design
summary
Build time drops from about 1 hour to 6 minutes by profiling and targeted refactors: use clang -ftime-trace and clang-build-analyzer to find hotspots in ~1,200 translation units, swap Make for Ninja, replace LD with lld or mold, add ccache, remove 500 transitive includes via forward declarations and a compilation firewall, introduce precompiled headers (20% win) and object libraries, and enable unity build judiciously — that cuts overall compile time 4–10× and reduces clang-tidy from ~2.5 hours to ~4 minutes.
AI-written summary · about
chapters (16)
- 0:00Introduction
- 1:13Why compilation times matter
- 2:58C++ compilation model
- 7:29Quick wins with build system
- 11:02Compiler caching
- 13:06Case study start
- 14:10Profiling with Clang tools
- 17:59Forward declarations
- 22:52Removing unused includes
- 24:56Splitting protocol and implementation
- 30:13Object libraries for linkage
- 32:16Pre-compiled headers
- 37:17Unity build
- 47:32Unity build challenges
- 49:57Results and static analysis
- 51:42Main takeaways and final recommendations
related talks
01h 44mImproving C++ Compilation Times: Tools & Techniques
56mPractical Techniques for Improving C++ Build Times
59mThe Hitchhikers guide to faster builds
53mWhy Is My C++ Build So Slow? Compilation Profiling and Visualization
05mHow To Profile Compilation Duration?
23mtoolchain-agnostic build time improvements
46mDeveloper Productivity at Scale
19mCOMPILING...? HOW TO REDUCE YOUR WAIT TIMES AND "GET BACK TO WORK"
