On Thu, 2025-06-26 at 19:21 +0200, wrotycz wrote:
> > > There are plenty of scenarios where using more jobs than
> > > processor threads results in faster builds: it all depends
> 
> You say that because you have tested it or because you believe it?
> I have tested it, But let's bust this ludicrous idea and show us a
> test that disproves me. Here is slightly improved test script

I don't see any need to be aggressive in your response.

Yes, I have tested it.  I have a large C program build using non-local
storage that has high bandwidth (can load multiple files in parallel)
but also high latency (satisfying any specific read is slow).  I can
get -j almost 2x the number of CPU threads before builds start slowing
down, because (a) the amount of CPU time needed to compile a C program
(in relation to other languages like C++ or Rust etc.) is relatively
little compared to the size of the source code, and (b) there's a lot
of latency of compilers waiting for files to be read over the network.

Of course none of this is very relevant to the issue under discussion.

> > > However, -j without any limit works the way it does because it is
> > > intended to be used in conjunction with -l.
> 
> I don't necessarily use it as I tried and have not seen any
> difference, but if you explain what it does I can prepare a test to
> actually examine it.

The -l (--load-average) option is described in the man page and in the
documentation:
https://www.gnu.org/software/make/manual/html_node/Options-Summary.html

If you run "make -j -l 4" for example it will run enough parallel jobs
to keep the CPU load at 4, more or less (basically, keeping 4 CPUs
busy).  If you use -l without -j, it's useless because you've not
enabled any parallelism.

That's the purpose of using "-j" with no argument: it means run as many
jobs as you can _subject to other constraints_... in this case load
level.

I'm not saying that it's the most amazingly designed interface, I'm
just explaining why -j with no arguments exists and works the way it
does.

One could imagine an interface like this, which might be easier to use:

 * -j by itself means the same as -j$(ncpus) or something similar.
 * -l automatically enables "full parallelism" (what "-j" does today)
   as a side-effect.
 * Both -l and -j limits by both number of threads and load average.
 * If the current "-j" is useful without "-l", add an option like "-j+"
   or something which enables it.

But, that's not how GNU Make currently works.  Whether it should be
changed is something to be discussed.  Changing the command line
interface of a 30+ year old program which is invoked probably hundreds
of thousands of times a day all over the world, is not to be taken
lightly.

Reply via email to