Increased compile time for interface generation and template instantiation

asked 2022-05-09 03:15:58 -0600

Hello everyone,

we are currently changing our messaging architecture from an internally developed library to ros2.

For this, we had to move over 450 different messages. These messages are now interfaces saved in a single library built with ament/cmake. (We tried separating the interfaces into multiple libraries but we found out that using interfaces of another library in an interface was not possible while building without colcon through conflicts in ament_cmake).

We noticed that we have a very high compilation time for the interfaces library (2m 16s on eight threads) and the library responsible for creating publishers and subscribers of these interfaces. In summary, our code now builds 9m 43s as compared to 3 min 35 s before the change. While we already performed some tricks to reduce the compile time (splitting up the instantiations of templates into separate compilation units and using precompiled headers), we still seek to find ways to reduce this compile-time onto reasonable levels.

Does anyone have an idea on how to achieve this? We already thought about:

  1. sparing out the generation process of c and python code for interfaces, as we only need the c++ interfaces, but experimenting around, we were not able to build interfaces only in c++ and we also did not find any questions related to this.
  2. Finding ways to reduce the time to instantiate a single template. Each instantiation of a subscription takes over 1 second and each instantiation of a publisher ~200 ms. This sums up to an impressive amount of time for 450+ messages.

Maybe some of you can provide us answers on the above ideas or have additional thoughts on how we can save compile-time.

Our Specs are: Ros2 - Galactic Ubuntu 20.04 Clang-11

Thanks in Advance

Segfault Creator

edit retag flag offensive close merge delete