ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
5

colcon build - number of threads

asked 2020-12-22 12:15:44 -0600

updated 2020-12-22 12:34:41 -0600

How Can I define the number of threads for a colcon building process in ROS2?

In previous ros building tools we used "-j {number_of_threads}", but that does not work anymore.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
7

answered 2020-12-31 00:48:03 -0600

Dirk Thomas gravatar image

There are two independent dimensions of parallelization:

  • The maximum number of packages processed in parallel when using the parallel executor. This dimension can be limited with the option --parallel-workers NUMBER. It can also be limited to 1 by selecting the sequential executor with --executor sequential.

  • The maximum number of threads used for a specific package using make. This can be controlled using the environment variable MAKEFLAGS. By setting e.g. export MAKEFLAGS="-j 4" only four threads are used to build a single package. By default colcon-cmake uses the number of available CPU cores (including hyper threading) to limit the number of threads (-j) as well as the system load (-l).

As a result the overall number of threads is the product of packages processed in parallel and maximum number of threads per package.

edit flag offensive delete link more

Comments

1

For anyone finding this, I found that colcon build on a Raspberry Pi 4 can crash, but adding --executor sequential sorted this out without a massive time penalty.

brianlmerritt gravatar image brianlmerritt  ( 2021-11-10 02:54:25 -0600 )edit
3

answered 2020-12-22 12:47:59 -0600

tfoote gravatar image

--parallel-workers NUMBER is the syntax you're looking for. "-j N" is a make specific argument.

There's documentation of the parallel executor command line options here: https://colcon.readthedocs.io/en/rele...

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2020-12-22 12:15:44 -0600

Seen: 10,431 times

Last updated: Dec 31 '20