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

Don't suggest to start build with infinite number of threads #1087

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Delgan
Copy link

@Delgan Delgan commented Apr 29, 2023

Hi.

Just a small enhancement proposal, as I don't think calling make with unbounded number of threads is desirable.

Using make -j will start "infinite" number of jobs according to make docs, which slows down the build and consumes too many resources.

Suggesting make -j4 seems to be a sane default, advanced users will know how to adjust it.


📚 Documentation preview 📚: https://cpython-devguide--1087.org.readthedocs.build/

@hugovk
Copy link
Member

hugovk commented Apr 29, 2023

Thanks for the suggestion.

What machine are you using? Does the build take longer with make -j than make -j4, or otherwise slow the machine down? "consumes too many resources" - in what way?

On macOS with 8 CPUs, make -j uses them all and I don't notice any other slowdown. Having said that, it takes about the same time to run as make -j4, around 32s.

@Delgan
Copy link
Author

Delgan commented Apr 29, 2023

Hi @hugovk.

It's not so much related to my machine in particular. It's just that once all the CPU cores are used for compiling, adding more jobs generally do not improve the performance and rather tend to make it worst because of the overhead of context switches 1. It's not very much noticeable in practice, though 23.

However, what is growing continuously is the RAM consumption. Each started job will consume memory, which causes a noticeable increase in overall RAM usage (finally "wasted" since an infinite number of jobs cannot run in parallel). This is not really desirable, and this is frequently related to out-of-memory problems for a beginner who is not familiar with make building process 4.

Also I suggested -j4 but maybe -j2 is preferable as it matches the example given when clicking "more detailed instructions" on the page.

Footnotes

  1. Disadvantages to high make job values

  2. How to speed up compilation time in linux

  3. GNU make: should the number of jobs equal the number of CPU cores in a system?

  4. Is make -j (with no argument) dangerous?

@terryjreedy
Copy link
Member

For the test suite, -j starts a number of parallel tests appropriate to the CPU. Since, you say, make -j does not do that, why not recommend -j# where # is appropriate for the machine?

@Delgan
Copy link
Author

Delgan commented Apr 29, 2023

@terryjreedy On the same page, tests are suggested to be run with ./python -m test -j3, details about the -j argument are only provided on the linked page. I suppose it's best to show a simple and functional example by default, and only go into detail on the appropriate page. It's easier to copy and paste. But in the end, it's up to what you prefer.

@willingc willingc added the needs: decision Needs consensus decision from core devs label Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement needs: decision Needs consensus decision from core devs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants