3 ms·
I assume templates can only be partly preprocessed (parsed?) but not fully pre compiled, since final code depends on the template types?
by klipt 3y ago
I assume templates can only be partly preprocessed (parsed?) but not fully pre compiled, since final code depends on the template types?
- vblanco 3y agoYes, but template code is all on headers, so it gets parsed every single time its included on some compile unit. With modules this only happens once so its a huge speed upgrade in pretty much all cases.
- moregrist 3y agoWhenever I’ve profiled compile times, parsing accounts for relatively little of the time, while the vast majority of the time is spent in the optimizer. So at least for my projects it’s a modest (maybe 10-20%) speed up, not the order of magnitude speed up I was hoping for. Thus C++ compile times will remain abysmal.
- dagmx 3y agoFor some template heavy code bases I’ve been in, going to PCH has cut my compile times to less than half. I assume modules will have a similar benefit in those particular repositories, but obviously YMMV
- jcelerier 3y agoDepends on the compiler, clang is able to pre-instantiate templates and generate debug info as part of its pch system - (for instance most likely you have some std::vector<int> which can be instantiated somewhere in a transitively included header). In my projects enabling the relevant flags gave pretty nice speedups.