You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if SageMath is built, it will use up more than number of parallel jobs specified by MAKEFLAGS, because make and ninja has no communication.
I notice that there are already tools to parse number of threads (./src/bin/sage-num-threads.py). At the very least we can throw -jN to ninja, so it would use at most 2N jobs.
For reference, at the moment (I don't fully understand how it work) pyproject_hooks is used to invoke build_wheel, which in turn delegates to mesonpy.
defbuild_wheel(wheel_directory, config_settings, metadata_directory=None):
"""Invoke the mandatory build_wheel hook. If a wheel was already built in the prepare_metadata_for_build_wheel fallback, this will copy it rather than rebuilding the wheel. """prebuilt_whl=_find_already_built_wheel(metadata_directory)
ifprebuilt_whl:
shutil.copy2(prebuilt_whl, wheel_directory)
returnos.path.basename(prebuilt_whl)
return_build_backend().build_wheel(
wheel_directory, config_settings, metadata_directory
)
We need to modify config_settings, which are done by modifying hook_input in
If I understood the code correctly, it suffices to set config_settings={"compile-args": ["-jN"]} (for some integer N), which is done by setting hook_input to {"kwargs": {"config_settings": {"compile_args": ["-jN"]}}}.
I don't know how hook_input is controlled.
Looks like it comes from sdh_build_wheel which calls python3 -m build, and you can somehow pass --config-setting=--compile-args=-jN to it using $#build 1.2.2.post1
which is in turn managed by sage/build/pkgs/cython/spkg-install.in
In top level pyproject.toml there is build-backend = 'mesonpy' specification. So passing -jN to that backend should be safe?
In sage-env, it already sets SAGE_NUM_THREADS and SAGE_NUM_THREADS_PARALLEL environment variables.
The text was updated successfully, but these errors were encountered:
`MAKEFLAGS` is an alternative to `MAKE`.
The note about `ninja` can stay there until
sagemath#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,
-->
<!-- - sagemath#12345: short description why this is a dependency -->
<!-- - sagemath#34567: ... -->
URL: sagemath#39128
Reported by: user202729
Reviewer(s): Julian Rüth, user202729
Currently, if SageMath is built, it will use up more than number of parallel jobs specified by
MAKEFLAGS
, becausemake
andninja
has no communication.I notice that there are already tools to parse number of threads (
./src/bin/sage-num-threads.py
). At the very least we can throw-jN
to ninja, so it would use at most2N
jobs.Partial work:
A process tree might look like the following.
For reference, at the moment (I don't fully understand how it work)
pyproject_hooks
is used to invokebuild_wheel
, which in turn delegates tomesonpy
.We need to modify
config_settings
, which are done by modifyinghook_input
inIf I understood the code correctly, it suffices to set
config_settings={"compile-args": ["-jN"]}
(for some integerN
), which is done by settinghook_input
to{"kwargs": {"config_settings": {"compile_args": ["-jN"]}}}
.I don't know how
hook_input
is controlled.Looks like it comes from
sdh_build_wheel
which callspython3 -m build
, and you can somehow pass--config-setting=--compile-args=-jN
to it using$#
build 1.2.2.post1which is in turn managed by
sage/build/pkgs/cython/spkg-install.in
In top level
pyproject.toml
there isbuild-backend = 'mesonpy'
specification. So passing-jN
to that backend should be safe?In
sage-env
, it already setsSAGE_NUM_THREADS
andSAGE_NUM_THREADS_PARALLEL
environment variables.The text was updated successfully, but these errors were encountered: