libadm icon indicating copy to clipboard operation
libadm copied to clipboard

Speed up build

Open tomjnixon opened this issue 3 years ago • 1 comments

libadm is quite slow to build, which makes it less pleasant to work on than it could be. This issue is here to collect ideas and track progress.

Some ideas:

  • build all the tests into one executable, and use catch cmake integration to make it nice to work with (some progress)
  • speed up compilation of individual objects, mostly by reducing the amount of code pulled in by headers
    • set up IWYU and follow it's recommendations (some progress)
    • where possible, use headers containing forward declarations of boost::optional and similar
    • improve the use of forward declarations in the library
      • currently elements_fwd.hpp isn't that useful, because headers for elements depend on ParameterTraits<T>::tag, which only works if the real header for T is included. This means that most of them end up including full headers for all other types. This can be improved by adding ParameterTraits overloads for all elements in type_traits.hpp or elements_fwd.hpp.
      • document.hpp should use elements_fwd.hpp, but document.hpp is used as a root header to include everything. It should probably be turned into a wrapper that includes elements.hpp and document_impl.hpp, and internal parts which need a definition of Document should be changed to include document_impl.hpp
    • consider moving implementations out of common headers like id_assignment.hpp and into implementation files. In this case the header should only need the forward declaration for IDs, not all the full declarations!

tomjnixon avatar May 10 '21 13:05 tomjnixon

Try profiling build time using (for example) https://devblogs.microsoft.com/cppblog/analyze-your-builds-programmatically-with-the-c-build-insights-sdk/ to identify what is slow.

Looks like clang has https://aras-p.info/blog/2019/01/16/time-trace-timeline-flame-chart-profiler-for-Clang/

rsjbailey avatar May 10 '21 14:05 rsjbailey