Compilation Speedup Using C++ Modules: A Case Study - Chuanqi Xu - CppCon 2022

Learn how named C++ modules can significantly speed up compilation, with a case study demonstrating a 2.32x to 1.7x increase in compilation speed using compiler optimizations and inlining.

Key takeaways
  • Named modules can provide significant speedup in compilation.
  • Inlining can help remove multiple deletions and improve compilation speed.
  • Function reduction can be useful for reducing compilation time.
  • The import extra limit option can control the threshold of lines of instruction to import modules.
  • Compiler optimizations such as Intraprocedural and Interprocedural optimization (IPO) can help improve compilation speed.
  • Single TU can be cheap and provide many compiler optimizations.
  • Modules can help reduce the number of inline functions.
  • The complexity theory can be correct but be too rough for users.
  • The study only talks about named modules and does not cover other types of modules.
  • The default value for import extra limit is 100.
  • The study shows that modules can provide a speedup of 2.32x for demo examples and 1.7x for tests.
  • The study uses a case study of a demo example to demonstrate the improvement in compilation speed.
  • The study also provides possible improvements in the future such as improving compiler side optimizations.
  • The study uses a traditional theory to explain why modules can be faster in compilation.