colcon / colcon.readthedocs.org

https://colcon.readthedocs.org
Creative Commons Attribution 4.0 International
10 stars 27 forks source link

Default value of --parallel-workers not explained #81

Closed ttikkanen closed 3 years ago

ttikkanen commented 3 years ago

Executor documentation states about --parallel-workers

The default value is based on the number of CPU cores

However, it doesn't say what is the logic. Will it be equal to number of CPU cores or threads? Or perhaps N-1 (preferable not to overload system).

https://colcon.readthedocs.io/en/released/reference/executor-arguments.html?highlight=parallel-workers#executor-arguments

christophebedard commented 3 years ago

See: https://github.com/colcon/colcon-parallel-executor/blob/1cb30600ff59c417710099232621e54201fa580b/colcon_parallel_executor/executor/parallel.py#L41

It's using os.cpu_count() and using 4 as a fallback.

From testing it on an Intel machine, it seems that os.cpu_count() returns the number of logical cores, e.g. 8 for a 4-core CPU with hyperthreading (so 8 threads).