Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not add two to the default job count #1449

Closed
wants to merge 2 commits into from

Conversation

Hello71
Copy link

@Hello71 Hello71 commented Jul 10, 2018

Benchmarks show that increasing the number of make jobs past the number of CPUs decreases performance: https://blogs.gentoo.org/ago/2013/01/14/makeopts-jcore-1-is-not-the-best-optimization/. This was conducted 5 years ago. Since then, although context switching itself has become faster, both CPU cache size and compiler memory usage have increased (the latter particularly so for C++). Moreover, compilers spend even less time on I/O now than they did then; any reasonable software package's header files will all fit into main memory. Therefore, I believe the results should be even more significant today.

Benchmarks show that increasing the number of make jobs past the number of CPUs decreases performance: https://blogs.gentoo.org/ago/2013/01/14/makeopts-jcore-1-is-not-the-best-optimization/. This was conducted 5 years ago. Since then, although context switching itself has become faster, both CPU cache size and compiler memory usage have increased (the latter particularly so for C++). Moreover, compilers spend even less time on I/O now than they did then; any reasonable software package's header files will all fit into main memory. Therefore, I believe the results should be even more significant today.
@Hello71
Copy link
Author

Hello71 commented Jul 10, 2018

Upon reconsideration, I think the value should be 1 for single CPU machines as well. Such machines are likely to also have low RAM, and so running more jobs than necessary is not only slower on the CPU, it may cause swapping.

@jhasse
Copy link
Collaborator

jhasse commented Oct 29, 2018

I think the idea behind the +2 is, that not all jobs are compiler invocations, so some are actually more IO heavy.

Also keep this point from the test in mind:

You need to switch your governor to performance.

If you don't do this, short IO breaks might cause the CPU to downclock and thus resulting in ${threads} + 2 being the better option, as it stresses the CPU nearly 100% of the time.

Windows might also act differently (process spawning takes longer there, Anti-Virus slows down IO, etc.). As an example I've just tested -j8 vs -j10 on a 4 cores + SMT machine on Windows 10 and -j10 won (19.416 s vs. 19.838 s).

All in all I'm not saying that we should never touch that default, but if we do, we have to be absolute sure, that the new default is better. Currently I don't think the benefit is worth touching this known behaviour.

@jhasse
Copy link
Collaborator

jhasse commented Nov 13, 2018

In order to reduce the number of open PRs I'm closing this one. If you still think this should be changed, please open an issue or start a thread on the mailing list.

@jhasse jhasse closed this Nov 13, 2018
@ocroquette
Copy link

ocroquette commented Feb 17, 2019

See also: https://groups.google.com/forum/#!topic/ninja-build/E3s9gE7RiLQ , #1363 and #1399
That would at least mitigate the issue when the default value is not optimal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants