[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug #49844] 'make -j' without explicit process count sometimes does

From: Sven C. Dack
Subject: Re: [bug #49844] 'make -j' without explicit process count sometimes doesn't parallelize
Date: Thu, 22 Jun 2017 13:01:36 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0


this isn't a bug, but it's how the -j option works.

From the manual:

       -j [jobs], --jobs[=jobs]
Specifies the number of jobs (commands) to run simultaneously. If there is more than one -j option, the last one is effective. If the -j option is given without an argument, make will not limit
            the number of jobs that can run simultaneously.

Specifying -j1 or -j 1 are the same here.

Your problem is that you are using numbers as target names. So it's not a bug, because you are literally telling make to run only a single job.

You either have to restrict the number of jobs by giving an explicit count or by limiting it with a load average ( -l option) or use non-numerical make targets such as "t1 t2 t3 ..." or simply add another flag after -j to make.

From my own experience is it generally better to limit the number of jobs to what is reasonable or otherwise risk setting off a fork bomb - a run-away process which spawns too many process too fast and brings the system to a halt.

If it really needs to be unlimited then using non-numerical targets is what you can do:

$ seq 1000 | sed 's,^,t,' | xargs -n1000 make -j

which results in:

$ make -j t1 t2 t3 ...

Or if it needs to be unlimited and it has to be numerical arguments can you simply do this:

$ seq 1000 | xargs -n1000 make -j -C .

which results in:

$ make -j -C . 1 2 3 ...

The -C option tells make to change the directory to the current directory and avoids the target 1 to be treated as an optional argument to -j.


On 21/06/17 20:39, Michael Builov wrote:
Follow-up Comment #1, bug #49844 (project make):


There is a bug in your trivial example:

1) 'seq 1000 | xargs -n1000 make -j5'

expands to

'make -j5 1 2 3 4 5 6 7 ...'


2) 'seq 1000 | xargs -n1000 make -j'

expands to

'make -j 1 2 3 4 5 6 7 ...'

As we can see, in second example '1' after '-j' make interprets as number of
jobs, so "it not do any parallelization at all".


Reply to this item at:


   Message sent via/by Savannah

Bug-make mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]