Closed kewp closed 5 years ago
You could try disabling the unity build. My understanding is with modern multicore cpus unity builds are actually slower; unless, you have a complex build system set up to take advantage of parallelism by unity building subprojects. It's somewhere between 4 and 8 physical / hyperthreaded cores where a unity build might actually be slower.
It could also just be the templates.
Actually, it's probably the templates. If I remember correctly, templates require a ton of recompiling bits of code. Which might completely invalidate the cache mechanism used by zapcc to speed up compilation.
How the header files are laid out could have an impact too. Try to write code where you can forward declare all types in headers, and get other headers out of header files that do anything other than forward declare types.
There are a ton of issues that could be causing compilation slowdown.
I have seen good speedup with regular Eigen in the past. Try disabling the unity build.
Ok. I disabled the unity build. Now it is much faster.
I thought something like that wouldn't matter - that every step of the compilation process was cached individually? How does pulling everything into one source file change that?
When you compile everything as one file 1 There is no chance for caching between compilation 2 Any change in the combined file invalidates the whole file
I thought that sub-processes were cached. How is using zapcc different than creating a makefile which only builds when dependent files change?
zapcc tries to cache as much as possible that does not depend upon the non-header files.
For instance, for Eigen it wil probably cache Matrix<float, 4, 4>
instantiation and generated code but will not cache Matrix<myfloat, 4, 4>
where myfloat
type is defined at a non-header file.
Not sure if I'm doing something wrong. Zapcc doesn't run faster than Clang. Even a bit slower.
I'm using Eigen, as well as a library with a ton of templating (autodiff). Also, I'm using a unity build. Any idea why the speedup isn't there?