Paul Smith <[email protected]> writes:
> On Fri, 2025-06-27 at 14:31 +0200, wrotycz wrote:
>> > Of course none of this is very relevant to the issue under
>> > discussion.
>>
>> I'm lost now.
>
> What I'm trying to say is that the exact number of jobs used as a
> default is not really that important. I have no problem saying that
> the default number (should we decide to use it) would be 1 * ncpu. I
> would not say, though, that it's completely obvious that this value is
> always the best in every situation, which was your original claim.
>
> The important, difficult, and time-consuming thing is to decide
> (a) whether to make the change in the first place, and, if so, (b) what
> the new behavior of the various options should be.
>
> There are two issues here: one is that "-j" has a poor choice for
> default behavior because it can cause hundreds of jobs to be spawned
> very quickly and bring the system to a standstill, which is bad.
>
> The other is that it's difficult to set a generic value for "-j" (say
> in a MAKEFLAGS environment variable, or even in the makefile itself)
> that works across a variety of systems with different CPU counts.
>
> Is it sufficient to solve the second issue without addressing the
> first? If so you could imagine supporting more complex values for
> "-j"; for example, "-jn" means "number of CPUs", while "-j2n" means
> "twice the number of CPUs", or something like that. This is a
> backward-compatible change so it's not so controversial.
>
> If you really want to address the first issue, the default behavior of
> "-j" with no argument, then that's a change to long-standing behavior
> so needs to be considered carefully.
Just want to voice my support for Paul's reasoning.
Using a default value for '-j' would not work in every situation. For
example, the 'ninja' command (similar to 'make' but meant to be written
by some meta-build tool like 'cmake' or 'meson') it defaults to a high
number of jobs:
$ ninja --help 2>&1 | grep -- '-j'
-j N run N jobs in parallel (0 means infinity) [default=18 on this
system]
When compiling LLVM, this number of jobs will make my system run
out-of-memory while linking. And when my system runs out-of-memory, it
is not very graceful. It freezes until I reboot it using the power
button.
If one wants to add a default value because they know it will always
work with their system they can easily add this to their ~/.profile:
export GNUMAKEFLAGS="$((2 * `nproc`))"
Assuming this is the value they want (and 'nproc' from Coreutils).
Collin