When spinning up multiple processes for parallel computing, it's useful to restrict the number of processes to the number of cpu cores available on a system in order to actually take advantage of those cores. However, knowing that number programmatically instead of hard-coding the value is as far as I can tell impossible.
For instance running the following code in a Node.js container will return
32
:
node -p "require('os').cpus().length"
. This is the same as Travis CI. But if we run
nproc
in Travis CI, we get the correct number (
2
) back, whilst on CIrcle we still get
32
.
So this is a feature request to make sure
nproc
returns the number of cores available to the container, and not the machine the container is running on.
---
An even better solution for my problem would be if the number of cores available to a build was injected as an environment variable, that way I can avoid doing a system call from my code. I can open up a separate feature request for that if you want?
CCI-I-578