-
Notifications
You must be signed in to change notification settings - Fork 297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interface specific compilation units #183
Conversation
Signed-off-by: Dirk Thomas <[email protected]>
d511f92
to
28c137a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I like the change and I think it is better to trade off slower compilation for less memory, especially for more memory constrained systems. Some notes:
- The inline comments are all nits.
- With this change in place, we should also update the README, as it says it takes a "tremendous amount of memory", which won't be true anymore (I noticed that the most memory is now used during link time, ~1GB resident).
- I'm not a huge fan of having the declaration for the
get_factory_<pkg>__msg__<msgname>
methods inside of thepkg_factories.hpp.em
file. It seems more natural for e.g.pendulum_msgs__msg__JointCommand__factories.cpp
to have the definition,pendulum_msgs__msg__JointCommand__factories.hpp
to have the declaration, and thenpendulum_msg_factories.hpp
#includependulum_msgs__msg__JointCommand__factories.hpp
. What do you think?
Signed-off-by: Dirk Thomas <[email protected]>
Squashing the last three commits. |
a1f6a18
to
79518bf
Compare
Done in cd0ef16. |
This has been that way before this patch, it is unrelated to this change and also not really necessary. Therefore I don't plan of changing it as part of this PR. |
In short: the PR trades a longer build time for a lower memory consumption during the build ⚖️
Resolves ros2/build_farmer#106.
Before the patch the generated code produced one
.cpp
file per package. The memory consumption of the compiler therefore scales with the number of messages per package and the template specialization stuff is not light on memory. For packages likegeometry_msgs
,sensor_msgs
orstd_msgs
which each contain ~30 messages the memory consumption of a single compilation unit could easily reach 2.5 GB. Building the bridge with N threads where N is by default the number of CPU cores could therefore easily exhaust the available memory.With the patch the generated code produces one
.cpp
file per interface file (message, service). Therefore the memory consumption for a single compilation unit drops to less than 0.5 GB. The trade off is that instead of generating X.cpp
files (where X is the number of interface packages it now generates Y.cpp
files (where Y is the number of interface files which is easily an order of magnitude higher). So while the peak memory consumption drops significantly the compilation time will increase. On my system with 8 cores it took ~3min 20s before and ~7min 45s afterwards.The two commits should not be squashed to keep the first commit which just duplicates one of the templates separate to ease tracking the history.