Robotics StackExchange | Archived questions

Slower performance of ROS2 Galactic with local build vs pre-built binaries

I've got pre-built binaries for ROS2 Galactic installed on my Ubuntu 20.04 machine. No issues with getting that going -- the demonodescpp & demonodespy test examples work as expected.

Checking into performance as part of some other investigations I'm doing, I compiled this package from Github: https://github.com/berndpfrommer/ros2_issues

Running that with RMW_IMPLEMENTATION=rmw_cyclonedds_cpp ros2 run ros2_issues publisher_node --ros-args -p num_elements:=50000 -p rate:=1000, I see the following performance numbers:

[INFO] [1650574539.746257732] [test_publisher]: pub rate:    31.25
[INFO] [1650574540.757245605] [test_publisher]: pub rate:    31.65
[INFO] [1650574541.775833948] [test_publisher]: pub rate:    31.42

Further, I'm able to build ROS2 Galactic Geochelone from source following the instructions here: https://docs.ros.org/en/galactic/Installation/Ubuntu-Development-Setup.html

No issues with that either. Running the demonodescpp and demonodespy test examples work as expected.

If I source my local build of ROS2, however, and run the "ros2_issues" package as above, however, I get the following performance numbers which are worse than with the pre-built binaries:

[INFO] [1650572322.229327451] [test_publisher]: pub rate:    10.90
[INFO] [1650572323.231439150] [test_publisher]: pub rate:    10.98
[INFO] [1650572324.236953146] [test_publisher]: pub rate:    10.94

Am I missing optimization issues with my local ROS2 build? Is something else at play?

Thanks!

TLDR: Building ROS2 Galactic locally vs using pre-built binaries is giving me markedly different results with a package that demonstrates ros2 performance issues. Any ideas what may be causing the difference? Is my local build missing optimization settings for compilation maybe?

Asked by AspireChef on 2022-04-21 16:01:03 UTC

Comments

Answers

Did you use the exact command given in the "from source" installation documentation you link?

If so: that doesn't appear to enable optimisations.

You could set the CMake build type using:

colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo

or straight Release, but perhaps still having debug info available is good while developing.

I'd probably clean out your workspace before rerunning colcon build, just to make sure.

This isn't the only way in which you can set CMake arguments, but it's an easy way to test whether this makes a difference.

Note that building from source isn't / shouldn't really be the default/first thing to do, so if you can use the provided binary packages, I'd do that.

Asked by gvdhoorn on 2022-04-22 04:09:11 UTC

Comments

@gvdhoorn You were 100% correct in your comment. I rebuilt with --cmake-args -DCMAKE_BUILD_TYPE=Release and now the performance matches the pre-built binaries. Thanks so much for the answer! I didn't realize the default build does not optimize for execution.

Asked by AspireChef on 2022-04-22 07:56:39 UTC