[Nix-dev] make -jx within builds?

David Brown nix at davidb.org
Fri May 28 16:38:58 CEST 2010


On Fri, May 28, 2010 at 03:04:07PM +0200, Marc Weber wrote:
>>   buildInParallel = makeSetupHook ...
>>     ''
>>       nrCores=$(cat /proc/cpuinfo | grep 'processor.*:' | wc -l)
>>       makeFlags="$makeFlags -j -l $nrCores"
>
>-j -l ? Agreed. This is superior.

I recommend still limiting the '-j', perhaps with the number of cores,
or twice the number of cores.  The load average lags behind, and this
can easily fire off dozens of compilations before the load catches up.
If you're short on memory, this can really hurt.

Also, the cpuinfo file is fairly processor specific.  It's better to
use something like:

   nrCores=$(grep -c '^cpu[0-9]' /proc/stat)

which should work on any architecture.

David



More information about the nix-dev mailing list