Skip to content

Commit f1b7e25

Browse files
AA-TurnerYhg1shugovk
authored
Ensure make -j uses a reasonable argument (#1541)
``make -j`` means no limit on the number of concurrent jobs, rather than a sensible number constrained by the system's resources. When building with LTO, it is easy to run out of memory when too many jobs run at the same time. Co-authored-by: Thomas Wouters <thomas@python.org> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
1 parent 26de2ef commit f1b7e25

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

developer-workflow/extension-modules.rst

+5-2
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,11 @@ Now that the configuration is in place, it remains to compile the project:
547547
548548
.. tip::
549549

550-
Use ``make -j`` to speed-up compilation by utilizing as many CPU cores
551-
as possible or ``make -jN`` to allow at most *N* concurrent jobs.
550+
Use ``make -jN`` to speed-up compilation by utilizing as many CPU cores
551+
as possible, where *N* is as many CPU cores you want to spare (and have
552+
memory for). Be careful using ``make -j`` with no argument, as this puts
553+
no limit on the number of jobs, and compilation can sometimes use up a
554+
lot of memory (like when building with LTO).
552555

553556
* ``make regen-configure`` updates the :cpy-file:`configure` script.
554557

getting-started/setup-building.rst

+6-7
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,13 @@ do to get a pydebug build of CPython.
203203

204204
Once ``configure`` is done, you can then compile CPython with::
205205

206-
$ make -s -j2
206+
$ make -s -j $(nproc)
207207

208208
This will build CPython with only warnings and errors being printed to
209-
stderr and utilize up to 2 CPU cores. If you are using a multi-core machine
210-
with more than 2 cores (or a single-core machine), you can adjust the number
211-
passed into the ``-j`` flag to match the number of cores you have (or if your
212-
version of Make supports it, you can use ``-j`` without a number and Make
213-
will not limit the number of steps that can run simultaneously.).
209+
stderr. The ``-j`` argument means that :program:`make` will concurrently run
210+
tasks, limiting the number of parallel jobs to the number of CPU cores in your
211+
computer. You can adjust the number passed to the ``-j`` flag to change
212+
the limit on parallel jobs, which can trade RAM usage versus compilation time.
214213

215214
At the end of the build you should see a success message, followed
216215
by a list of extension modules that haven't been built because their
@@ -875,7 +874,7 @@ some of CPython's modules (for example, ``zlib``).
875874

876875
And finally, run ``make``::
877876

878-
$ make -s -j2
877+
$ make -s -j $(nproc)
879878

880879
There will sometimes be optional modules added for a new release which
881880
won't yet be identified in the OS-level build dependencies. In those cases,

index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ instructions please see the :ref:`setup guide <setup>`.
4343

4444
.. code-block:: shell
4545
46-
./configure --with-pydebug && make -j
46+
./configure --with-pydebug && make -j $(nproc)
4747
4848
.. tab:: macOS
4949

5050
.. code-block:: shell
5151
52-
./configure --with-pydebug && make -j
52+
./configure --with-pydebug && make -j $(nproc)
5353
5454
.. tab:: Windows
5555

0 commit comments

Comments
 (0)