Does the C++ compiler work too hard?
summary
Analysis of large C++ projects shows compiler cost dominated by per-invocation work and translation-unit size rather than optimization level. Measured on Unreal Engine (full build ~5 hours) with 24,000 compilation units collapsing to 2,300 with unity builds cuts time dramatically, and precompiled headers take 4 minutes but make a module go from 700 to 500 minutes. Object file size correlates strongly with compile time, O3 vs Os vs Oz changes little, sqlite single-file inl units are surprising outliers, and results hold across Clang and GCC.
AI-written summary · about
chapters (9)
- 0:00Introduction and motivation
- 1:38Analyzing Unreal Engine builds
- 4:08Build optimization strategies
- 7:45Compiler behavior patterns
- 13:20Correlation of size and time
- 19:01Deep dive into Unity builds
- 22:48Parallel compilation impacts
- 25:21Outliers and optimization tests
- 30:28Cross-project results and closing
