Skip to content

Commit d0e72a6

Browse files
author
Release Manager
committedFeb 21, 2025
gh-39128: Add note about makeflags and ninja parallelism `MAKEFLAGS` is an alternative to `MAKE`. The note about `ninja` can stay there until #38950 is fixed to warn the user e.g. to not run too many other things in parallel. It would be rather surprising if you pass `make -j3` there and have 7 processes running in parallel (which might eat up a lot of RAM and possibly have the OOM killer kill other processes along the way). ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - #12345: short description why this is a dependency --> <!-- - #34567: ... --> URL: #39128 Reported by: user202729 Reviewer(s): Julian Rüth, user202729
2 parents 067ebbd + 2af2e49 commit d0e72a6

File tree

4 files changed

+34
-21
lines changed

4 files changed

+34
-21
lines changed
 

‎README.md

+12-6
Original file line numberDiff line numberDiff line change
@@ -334,12 +334,18 @@ in the Installation Guide.
334334
11. Optional, but highly recommended: Set some environment variables to
335335
customize the build.
336336

337-
For example, the `MAKE` environment variable controls whether to
338-
run several jobs in parallel. On a machine with 4 processors, say,
339-
typing `export MAKE="make -j4"` will configure the build script to
340-
perform a parallel compilation of Sage using 4 jobs. On some
341-
powerful machines, you might even consider `-j16`, as building with
342-
more jobs than CPU cores can speed things up further.
337+
The `MAKEFLAGS` variable controls whether to run several jobs in parallel.
338+
To saturate all the execution threads of your CPU, we recommend to run
339+
`export MAKEFLAGS="-j$(nproc) -l$(nproc).5"` if you are on Linux, and
340+
`export MAKEFLAGS="-j$(sysctl -n hw.ncpu) -l$(sysctl -n hw.ncpu).5"` if you
341+
are on macOS.
342+
343+
Note that the compilation may nonetheless use a different number of
344+
processes, e.g., for parts that are built with `ninja` which automatically
345+
decides on the amount of parallelity to use. In practice, you might
346+
therefore see twice as many processes during the build process than your
347+
CPU has execution threads. Unless your system is low on RAM, this should
348+
not affect the time the compilation takes substantially.
343349

344350
To reduce the terminal output during the build, type `export V=0`.
345351
(`V` stands for "verbosity".)

‎src/doc/en/faq/faq-usage.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ Sage. The command
7070

7171
.. CODE-BLOCK:: shell-session
7272
73-
$ export MAKE='make -j8'
73+
$ export MAKEFLAGS='-j8'
7474
7575
will enable 8 threads for parts of the build that support
7676
parallelism. Change the number 8 as appropriate to suit the number of

‎src/doc/en/installation/source.rst

+20-13
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,8 @@ Environment variables
669669
Sage uses several environment variables to control its build process.
670670
Most users won't need to set any of these: the build process just works on many
671671
platforms.
672-
(Note though that setting :envvar:`MAKE`, as described below, can significantly
673-
speed up the process.)
672+
(Note though that setting :envvar:`MAKEFLAGS`, as described below, can
673+
significantly speed up the process.)
674674
Building Sage involves building many packages, each of which has its own
675675
compilation instructions.
676676

@@ -680,19 +680,26 @@ Standard environment controlling the build process
680680

681681
Here are some of the more commonly used variables affecting the build process:
682682

683-
.. envvar:: MAKE
683+
.. envvar:: MAKEFLAGS
684684

685-
One useful setting for this variable when building Sage is
686-
``MAKE='make -jNUM'`` to tell the ``make`` program to run ``NUM`` jobs in
687-
parallel when building.
688-
Note that some Sage packages may not support this variable.
685+
This variable can be set to tell the ``make`` program to build things in
686+
parallel. Set it to ``-jNUM`` to run ``NUM`` jobs in parallel when building.
687+
Add ``-lNUM`` to tell make not to spawn more processes when the load exceeds
688+
``NUM``.
689+
690+
A good value for this variable is ``MAKEFLAGS="-j$(nproc) -l$(nproc).5"`` on
691+
Linux and ``MAKEFLAGS="-j$(sysctl -n hw.ncpu) -l$(sysctl -n hw.ncpu).5"`` on
692+
macOS. This instructs make to use all the execution threads of your CPU while
693+
bounding the load if there are other processes generating load. If your
694+
system does not have a lot of RAM, you might want to choose lower limits, if
695+
you have lots of RAM, it can sometimes be beneficial to set these limits
696+
slightly higher.
697+
698+
Note that some parts of the SageMath build system do not respect this
699+
variable, e.g., when ninja gets invoked, it figures out the number of
700+
processes to use on its own so the number of processes and the system load
701+
you see might exceed the number configured here.
689702

690-
Some people advise using more jobs than there are CPU cores, at least if the
691-
system is not heavily loaded and has plenty of RAM; for example, a good
692-
setting for ``NUM`` might be between 1 and 1.5 times the number of cores.
693-
In addition, the ``-l`` option sets a load limit: ``MAKE='make -j4 -l5.5``,
694-
for example, tells ``make`` to try to use four jobs, but to not start more
695-
than one job if the system load average is above 5.5.
696703
See the manual page for GNU ``make``: `Command-line options
697704
<https://www.gnu.org/software/make/manual/make.html#Options-Summary>`_
698705
and `Parallel building

‎src/doc/it/faq/faq-usage.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ questi prerequisiti come segue::
7070
Se hai un sistema multiprocessore puoi scegliere una
7171
compilazione parallela di Sage. Il comando ::
7272

73-
export MAKE='make -j8'
73+
export MAKEFLAGS='-j8'
7474

7575
abiliterà 8 threads per quelle parti della compilazione che supportano
7676
il parallelismo. Al posto del numero 8 metti il numero di

0 commit comments

Comments
 (0)
Please sign in to comment.