Effect of Clang modules on compilation time

Hello, module enthusiasts! I’ve investigated the effect of Clang modules on compilation time in a few projects and would like to share the results. There are no big revelations but it is nice to see concrete numbers for our beloved LLVM+Clang codebase. I’m not aware of similar data collected for other projects, so if anybody has any pointers, I’d be glad to learn about such endeavours.

1 Like

Thank you for the detailed study. I am really interested in how compile for Clang modules and ISO C++ modules will compare.

IIRC, clang-scan-deps only finds the dependencies for headers and ignores ISO C++ import statements.

Yes, such comparison would be interesting for completeness. Though I don’t expect any compile-time breakthroughs from ISO C++ modules as the main improvement of not parsing the same headers multiple times is already achieved by Clang modules. There is a space for improvement with templates but I don’t think ISO C++ modules cover that. And for incremental builds I don’t follow standard process enough to know the desired granularity of tracking dependencies for ISO modules. So it might fall in the same trap of invalidating and rebuilding too much.

For clang-scan-deps I think you are right. At least, in the tests I don’t see any C++ import/export.

The main benefit of named modules is that the named modules are standalone TU. So the code in named modules would only be compiled once in the optimizations (depends on the setting) and the backend code generations.

Nice read and interesting results, thanks for sharing!

1 Like