It allows it to be overridden in the individual builds by setting OPAMJOBS. However, since we don’t implement a jobserver protocol, setting it to anything other than 1 and doing parallel package builds results in the machine being overcommitted. (i.e. if you install 5 packages in parallel, then they will all spawn 5*NCPU jobs).
It’s worth opening an issue in ocaml/dune on this, since it could implement a jobserver protocol fairly easily, and then opam could pass on this information to both dune and make to reduce the overcommit.
The whole story is still a bit unclear on what is best to me.
You have different kinds of parallelism:
opam building independent packages in //
The package itself using a // build system.
For example the performance impact of having four packages building in parallel each using 4 auto-discovered jobs on a 4 core machine is unclear to me.
So in some sense it might be better to letter opam determine that jobs number rather than let each individual packages auto-discover it.
Also I can’t find discussions about this again but note that it was never really clear in opam whether OPAMJOBS and that jobs variable was 1. or 2. but I think that nowadays it is defacto 2.
I see the point that opam knows more about the global workload and might pass on this information to dune. In particular, opam itself accepts a -j parameter but I don’t think -j 1 implies that installation on the dune level cannot use concurrency.