Other things besides badly setup precompiled header files can
cause slow build times.
For instance, I was optimizing build times on one project
and I noticed that one DLL was exporting about two thousand
functions and classes (_dllexport) when it only needed to export
two functions. This was slowing down the build for two reasons:
- The export table was about 1 MByte, due to the long decorated
names.
- The inline member functions and
automatically generated class functions, like operator= and
the copy constructor, were being generated for some classes in
every single source file! Why? Because each source file knew that
these classes were exported and new that somebody had to generate
these functions and didn't know whether any other source files would
generate them. This created many megabytes of redundant code that
the linker then had to remove.
Clearly if thousands of functions are being redundantly generated
hundreds of times this is going to do bad things to your build times.
Also, the project had many small source files. Each file took about 1.5
seconds to build. If I merged twenty source files together then the
merged file took about 1.6 seconds to build. In other words, by sensibly
merging some source files I could speed up the build pretty much as much
as I wanted to. This is a build optimization that works on virtually all compilers.
The morals?
- Don't export functions or classes that don't need exporting.
- Don't include enormous class definitions from hundreds of source files.
- Be wary of the automatic operator= and copy constructor functions
for large classes since they are implicitly huge inline functions.
- Be wary of the interaction between inline functions and _dllexport.
- Small source files can be very inefficient.
Please
contact me
if you have any questions.
Why Buy FX? |
Download Area |
How to Buy FX |
The Gallery
Fractal Theory |
Comments Area |
Company Profile |
Tips & Tricks
Main Page |
Links |
Send Mail
|