Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Why nproc + 1?

50 views
Skip to first unread message

lawren...@gmail.com

unread,
Oct 9, 2016, 10:16:35 PM10/9/16
to
Why is the recommendation for running builds as fast as possible to use

make -j$(($(nproc) + 1))

rather than

make -j$(nproc)

?

By the way, never use

make -j

Kaz Kylheku

unread,
Oct 9, 2016, 10:29:01 PM10/9/16
to
On 2016-10-10, lawren...@gmail.com <lawren...@gmail.com> wrote:
> Why is the recommendation for running builds as fast as possible to use
>
> make -j$(($(nproc) + 1))
>
> rather than
>
> make -j$(nproc)
>
> ?

This is because make jobs can become I/O bound.

You are not ray-tracing or cracking passwords.

If you have a mixture of I/O and computation, the mix can benefit from
the use of multiple processes.

Suppose you have only one processor, and you run the build steps as one
process. When that process blocks on I/O, nothing happens until it
unblocks. An opportunity is possibly missed to be compiling something.

This generalizes to muliple processors.

That opportunity is not *great* because the build doesn't involve that
many different storage devices (often just one). That's why it's not
"nproc + 15" or "nproc * 2". Just + 1.

lawren...@gmail.com

unread,
Oct 10, 2016, 12:31:21 AM10/10/16
to
On Monday, October 10, 2016 at 3:29:01 PM UTC+13, Kaz Kylheku wrote:
> That opportunity is not *great* because the build doesn't involve that
> many different storage devices (often just one). That's why it's not
> "nproc + 15" or "nproc * 2". Just + 1.

Ah, so with I/O on a single device interleaved between different processes, the assumption (best case) is a single process blocked on I/O at any one time, leaving n processes ready to run?

So if the files were on an i-way striped array, you could usefully run n + i processes at once, then...
0 new messages