[Nix-dev] Re: Parallel building support, 1st attempt

Peter Simons simons at cryp.to
Tue Jun 22 19:43:29 CEST 2010


Hi Ludovic,

 >>  1) Nix-env provides the environment variable $NIX_BUILD_CORES. The
 >>     default value is 1, which is equivalent to building with
 >>     parallelism disabled.
 >
 > It should be a ‘nix-store’ option IMO, so that it’s available to all the
 > commands that builds on it (‘nix-build’, ‘nix-env’, etc.).

uh, right. I think that's the case, actually, but it didn't occur to me
to test whether I modified things in the right spot. I'll have another
look, we certainly want that options supported on all relevant commands,
not just nix-env.


 > Also, it should be able to guess a good default value when asking for
 > parallel builds, using sysconf(3) or some such (see Gnulib’s ‘nproc’
 > module.)

Yeah, that would be nice. Right now, "build-cores <n>" treats both n=0
and n=1 as "n=1". It might be okay to interpret n=0 as "guess". Does
that sound okay?


 >>  2) The generic builder checks whether $enableParallelBuilding is
 >>     set. If it is, "-j{NIX_BUILD_CORES} -l{NIX_BUILD_CORES}" is
 >>     added to $makeFlags.
 >
 > FWIW I prefer Lluís’ suggestion of using substituters for this since
 > it’s completely orthogonal and makes it clear that the user asserts
 > that the build output isn’t dependent the number of parallel build
 > processes.

Fair enough. Unfortunately, I don't know much about substituters, so I
can't say whether that approach might be better or worse that the
solution I implemented.

Take care,
Peter




More information about the nix-dev mailing list