May 8, 2017
Having failed utterly at using
extern template to reduce compile time, I am attempting to use a "unity" build (master build, etc) to improve compile time.
The first step was to manually produce a
unity.cpp file which
#includes all the
.cpp files for the core library. No problem, < 3 mins manual effort on that one.
Then, to make a new
Makemodule.am file (name arbitrary) to describe how to build
libbertini2.la with the unity source file.
Unity has been implemented, let's test it out! I compiled with
-O2 in Clang coming with XCode 8.
Unity, single thread: 1m15s. Incremental, single thread: 4m08s.
30% of original time, saving 70%. This is just for the
core library and nearly-trivial
blackbox program, and not including building the tests (I only made up a
unity.cpp file for the core).
Since my little virtual build server farm (Thanks CRC!!!) consists of virtual machines without a lot of CPU's, this may prove beneficial. I do, however, need to make sure that the memory usage doesn't go crazy. Sometimes my
.cpp files can take a ton of ram, due to the extensive use of templating...
I am pretty happy with the "unity build" thing. It appears to have lead to a 70% reduction in single-thread compile time for the core.
A last note: multithreaded compilation was still faster... Because I can use 8 threads on my Mac. So, this style of build should remain an option, not a requirement. I will add a
--with-unity_build option to the
configure.ac file, so a user can choose to use it. A last question: which to make default, unity or incremental?