-
Notifications
You must be signed in to change notification settings - Fork 58
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
The compile times are super slow #125
Comments
I compiled the test suite with Clang 9's new
Those are some preliminary results, more to come later. |
The branch I plan to merge the branch once Catch2 3.0.1 is officially released. |
This isn't new, but the huge template mess everywhere in the library means that the compile times are slow, and they are currently even more terrible in the mutable sorters branch (which doesn't matter for now because it is blocked by internal compiler errors in clang++, but still...). However reducing those compile times without breaking the current API and reducing the power of the wrappers seems tricky. To be honest, I don't even know where to start to reduce the evergrowing template instantiations that occur everywhere. I tried a few things knowing that it wouldn't change much:
std::decay_t
byremove_cvref_t
choice
mechanism inhybrid_adapter
to reduce its recursive instantiations from 127 to <30 most of the timesorter_facade
to implement sorter adapters when they can already handle all theoperator()
overloads by themselvesIt decreased the debug executable size a bit, but that's pretty much the only noticeable achievement.
But in the grand scheme of things it doesn't change much. I am looking for ideas to reduce a bit the compile times without breaking the library API, but I've only got a few tiny ideas:
using
when possible generally ends up in the compiler instantiating fewer templates, which may help reduce both binary size and compile times. (I did that in a few places, now I don't know where it might still be relevant)sorter_facade
derivatives for specific sorter implementations since the ones in the library mostly have the same functions, but it doesn't look easy to make it work generically for user-defined sorters without introducing more tags.std::conjunction
and friends are apparently slow and probably unneeded in most places; I should analyze the library to reduce their uses if possible.std::move
andstd::forward
by a bunch ofstatic_cast
, even though it doesn't look like the cleanest thing to do. (I tried that forstd::forward
and didn't notice a difference)std::distance
by subtractions when functions only handle random-access iterators may decrease the amount of tag dispatch happening (same for other iterators operations). It might also make it obvious when code is designed to work with random-access iterators only._EnableIf
that don't trigger template instantiations, which might be worth considering if they improve the state of things. On the other hand we should check whether it makes error message worse or not, because Error messages are unreadable #28 is a thing too.Those are only small changes, and I doubt that it will make a difference. If anyone has better ideas to reduce the compile times without breaking the API, I welcome such ideas :p
List of articles about speeding up compilation of templates and related stuff (suggest articles if needed):
The text was updated successfully, but these errors were encountered: