How to reduce colcon build time

asked 2022-11-02 04:45:38 -0500

KimJensen gravatar image

I am currently building my ROS2 Galactic software stack directly on an RPI CM4, which takes ~45 min from scratch. On my computer, it takes ~5 min to build the same software stack. The software stack contains various packages, custom msgs, custom interfaces, etc. My goal is to reduce the time it takes to build this software stack on the CM4, hence optimizing the development workflow. Do you guys have any suggestions on how to achieve this?

I've considered using cross-compilation using Docker, but I'm unsure if this will speed up the build process. This source writes about this.

Specs:

  • Ubuntu 20.04
  • ROS2 Galactic
  • Target system: RaspberryPI CM4
edit retag flag offensive close merge delete

Comments

Building (lots of small) packages can often be IO-bound. Most RPis use sdcards or similar, which are not known for their high performance (ie: max IOPS). Low-latency storage is important here. CPU-wise an RPi is also vastly underpowered compared to a regular desktop CPU, but storage latency should not be ignored.

Oh, and pedantic, but this is not Colcon, but CMake. Colcon overhead is negligible.

gvdhoorn gravatar image gvdhoorn  ( 2022-11-02 05:14:20 -0500 )edit

Thank you for your answer. It provides a nice understanding of why it is naturally slower to build on the CM4. My CM4 comes with built-in 32 GB eMMC storage, so I won't be able to do much about the storage performance. What would your recommendation be to reduce the build time, as I can't do much about my available hardware? Cross-compilation using Docker, CMake optimization, simply accepting the fact that the CM4 is just that much slower than a laptop, or any other suggestion?

Sorry if the post is inappropriate, as you now state that it is CMake, and not the colcon overhead, which is causing the long build times.

KimJensen gravatar image KimJensen  ( 2022-11-02 10:57:48 -0500 )edit

If you have a true cross-compiler (so not emulation using qemu-static or something) that would probably be the fastest way to build your system.

You may even want to look at using something like meta-ros (ie: Yocto). If you're deploying to products, I'd invest into pipelines like that.

gvdhoorn gravatar image gvdhoorn  ( 2022-11-02 12:37:38 -0500 )edit

Do you have an example of where to start if I were to have/create a true cross-compiler? I assume it means specifying a cmake toolchain and creating a sysroot of the RPi. Any literature/sources would be much appreciated.

KimJensen gravatar image KimJensen  ( 2022-11-09 03:05:44 -0500 )edit