Template instantations are killing me
May 2, 2017
I perhaps have overused templates in Bertini2. It's true. I am in love with templates, and just keep using them. But, compile time is killing me. It is taking forever to compile Bertini2, and I want it to be faster. 30 minutes build-test times on my Jenkins servers is unacceptable.
So, here I go!
First attempt: -ftime-report
My first attempts to understand which templates are taking so long is to attempt to get information from GCC/Clang during compilation.
Per this SO post, u/Schamp asks about a different but similar scenario. /u/anon replies to use -ftime-report
, to get some information. I did not find it useful at all. Maybe I don't understand correctly how to read the output? Let's try another tool.
It's not so useful to me. I want to see which particular template instantations are taking so long. Is it stuff from Boost.Multiprecision? Eigen? My own crazy large templates?
Second attempt -- Templight
Another SO post has an answer from u/Mikael Persson, suggesting a tool called Templight, of which they are an author. So I figured I'd give it a try.
0. Compiling Templight
It's not a simple brew install templight
sadly, but instead requires building it with LLVM/Clang. I've been readying myself mentally to use LLVM, so this seems like as good a time as any to just install it from source. Ok, so I use the install instructions for Clang, and those for Templight on their readme
. I download the SVN for Clang and LLVM, versions 301787 and 301782 respectively. The patching step for Templight fails. Bummer.
I viewed the issues for templight, and found [#38](https://github.com/mikael-s-persson/templight/issues/38) gives a known good version of templight commit 0738fa1, and clang rev number 289544. Patch applied cleanly. Project builds smoothly.
Then, I run the tests for Clang.