Have `nproc` accurately reporter number of CPUs available to container
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
node -p "require('os').cpus().length". This is the same as Travis CI. But if we run
nprocin Travis CI, we get the correct number (
2) back, whilst on CIrcle we still get
So this is a feature request to make sure
nprocreturns 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?