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.
Originally posted by Dirk Thomas with karma: 16276 on 2020-12-31
This answer was ACCEPTED on the original site
Post score: 7
Original comments
Comment by brianlmerritt on 2021-11-10:
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.