-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
optimize build time (precompiled headers) #1800
Conversation
Interesting. What if you add |
That's a bad idea for incremental builds - if you do an ever-so-slight change to any header, it'll cause a recompilation of every single translation unit in the whole code base. It's best to add only headers that hardly ever change. The standard headers and boost ones that are used most often throughout the library are the best candidates. QuantLib's own headers shouldn't be included unless they are both never really touched (e.g. in months) and included in several translation units (to get a compile time gain). Best is to avoid them completely. |
Well, I included the headers that are most expensive according to the results from ClangBuildAnalyzer described in #1787. I guess we could replace |
The comment was more about putting the full Does the build analyzer allow showing only the third party headers, sorted by time spent + number of includes in total? Usually the boost headers and streams tend to be expensive to parse + they are included a lot. Regarding infrequent changes to those QuantLib headers: Also consider the indirect includes of these. They should be very stable too. Another point to be aware of with precompiled headers: Cmake puts an implicit include of all the listed headers into every translation unit. (That's why all files get recompiled if any of these headers are touched.) This can lead to developers forgetting to include files they need explicitly, potentially causing issues for third party users of the library. But I believe there's already a CI/CD workflow guarding against that... |
ClangBuildAnalyzer has very few options, I don't know how to filter on external headers. On your last point. Indeed, I just ran into an issue because |
There are complications when using ccache though: https://ccache.dev/manual/3.2.4.html#_precompiled_headers |
cmake seems to use |
Ah yes, I observe this in my local builds as well, that's nice. As for the sloppiness I can enable that in our docker build by adding an environment variable
I suppose something similar will be possible in the GitHub workflows? |
Yes, it's possible to define env variables, no problem. I'm somewhat surprised that |
Looks like
and
|
Both are listed as expensive headers / template instantiations by ClangBuildAnalyzer. I think we should remove It's probably similar for |
While testing this I notice that when using clang an additional flag |
@pcaspers Are you looking at full or incremental builds? If it's for the former, maybe it can be an option like unity builds. Maybe even combined with it. |
I have added a cmake flag |
Playing with pre-compiled headers as an alternative way to speed up the build - these are pretty easy to add to a cmake build and have quite an impact on parse times:
baseline (target ql_library only)
after change
Thoughts? Is this a no-brainer or am I overlooking issues introduced by that?