Save the Build with Precompiled Headers
It seems that one of the least discussed factors affecting software development productivity is the software build time (or compile time). Perhaps that's because so much of software has gone the way of the web that build time is less of a concern for most of the industry, but for us C/C++ types build time can be critically important. The faster our build times the more often we can build/run/test, leading to features being implemented and bugs getting fixed in shorter iterations.
There are many factors that can affect build time, including the specs of the machine building the software, software structure and dependencies, and project size. And finally there's one thing a lot of engineers seem to overlook: precompiled headers.
Using precompiled headers won't give you a small boost in build speed. No, we're talking several orders of magnitude decrease in the build time in some cases. This is a Good ThingTM.
As an example, a project I work on did not use any precompiled headers for its initial development. Build times were starting to increase substantially as the codebase grew, partially because it uses a lot of 3rd party libraries. At this stage in development, the lines of code count was hovering around the 60 KLOC mark (or 60,000 LOC) with around 300 KLOC in 3rd party libraries. The typical build time had increased to around 10 minutes on average.
So after determining that a good chunk of the code in the project rarely changed, we decided that precompiled headers should be added to help with the build time. We also created a standard header file that #include'd all of our 3rd party libraries and made that a precompiled header. Build times dropped to around 3 minutes. The benefit was substantial. Granted, we've used precompiled headers in the past and we knew the benefit, but we were still impressed with this level of improvement.
There's a lot of documentation out there on precompiled headers, but my favorite is by Noel Llopis from 2005, which even provides a Python script to analyze your project and identify potential areas for precompiled headers: Games From Within: The Care and Feeding of Pre-compiled Headers. Wikipedia also has an entry.
Filed under: Development, Software