C++ #include on a Diet
summary
Large legacy C++ codebase (≈3.5M LOC, ~180 Visual C++ projects, 60,000 #includes in .cpp files) undergoes automated pruning by iteratively removing each #include, recompiling with cached Clang command lines produced via Clang Power Tools, using precompiled headers and file-level parallelism; outcome is 34% reduction (≈20,000 includes removed, ~3 removed per touched .cpp across ~4,000 files), a ~5% build-time speedup, and catchable pitfalls like link-time externs and macro-guard variants; future: monthly pipeline and header pruning; alternative tools tried: include-what-you-use and Visual Studio include cleanup.
AI-written summary · about
chapters (6)
- 0:00Motivation for header pruning
- 8:56Defining the problem
- 12:02Evaluating potential strategies
- 26:25Developing the automation engine
- 39:27Optimization and parallelization
- 42:06Results and lessons learned
related talks
04mInclude Cleanup and Diagnostics in Visual Studio
34mPractical C++20 Modules and the future of tooling around C++ Modules
53mDebug C++ Without Running
01h 31mClean(er) Code for Large Scale Legacy Applications
10mStay in tune with your build using Build Insights
01h 00mDebug C++ Without Running
01h 00m“Deploying C++ modules to 100s of millions of lines of code"
01h 01mHow to Refactor Millions of Line of Code Without Alienating your Colleagues
