-
-
Notifications
You must be signed in to change notification settings - Fork 491
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
Parallel docbuild, cythonization: Use GNU make's POSIX jobserver protocol #30369
Comments
comment:2
Copying my comment from #30345: We're having trouble here because we're conflating two different things. The sage distribution has a top-level makefile that's used to initiate high-level tasks -- in particular installing SPKGs -- convenient to execute. Many of those high-level tasks themselves have build systems, separate from sage, that involve Make. We're passing the distribution's When in doubt, copy Gentoo: our package manager has So, my suggestion: we copy Gentoo, and create something like a I think that's less complicated that trying to coordinate the two levels, and doesn't wed us further to GNU's implementation of Make. |
comment:3
IIRC, Sage cannot be built with a nonGnu make, anyway. IMHO Gentoo's way looks a bit like a workaround for old buggy Gnu Make. |
comment:4
Replying to @orlitzky:
No, the point of the jobserver is that one does NOT have to distinguish these "two different things". The jobserver manages the load. We do not have a problem with the jobserver. We are careful to pass down the make options to sub-makes. This works. We have a problem with the python-based build systems that do not use the jobserver, and this ticket proposes a specific way to solve it. |
comment:5
Replying to @dimpase:
The Makefiles generated by autotools are POSIX compatible, it's only the hand-written Makefiles that are a problem. We generate those with a bootstrap script anyway, so at least in theory it would be possible to coerce them into being POSIX compatible.
It's just a way to let users specify how many jobs should be used to build each package in a source-based distribution. The number of packages that will be installed simultaneously is something else. Our situation isn't much different, except that the "package manager" is also Make. |
comment:6
Replying to @orlitzky:
Users should have no reason to be interested in this distinction. All that matters is throughput. |
comment:7
Replying to @mkoeppe:
You can certainly integrate the two cleanly with the jobserver approach, but that doesn't change my opinion that they're conceptually two different quantities. The first is how many high-level tasks I'd like to run at the same time (doc building, package installation), and the second is how many threads I'd like to use to perform each of those tasks.
Maybe not, but we could default both to the same number to accomplish that out-of-the-box. Experience has shown that most people are happy with one package installation at a time, and then a configurable number of jobs. High-level tasks are generally free, while low level ones tend to chew up CPU/RAM. What I personally care about is the number of low-level build threads, which should be the number of package-installation threads times the number of per-package-build-threads. Again using Gentoo as an example, I usually leave this at one package at a time, and then ~four build threads per package. |
comment:8
Replying to @orlitzky:
Sorry, this does not match the typical experience in Sage at all. Throughput comes from building many packages in parallel. |
comment:9
One other thing that distinguishes Gentoo and sage-the-distribution is that Sage is fortunate enough to only have C, C++, Fortran, and python packages for now. Some day that will probably change, and then it's a lot simpler to pass a flag to whatever newfangled build system is involved than it would be to integrate that build system with the GNU Make job server. |
comment:10
Replying to @orlitzky:
such as ninja? Note https://github.com/Kitware/ninja/releases, https://forums.gentoo.org/viewtopic-t-1110292-view-previous.html |
comment:11
Replying to @mkoeppe:
I actually had Meson in mind, but this is also a good example. Utilizing the job server has the potential to be more efficient, if e.g. you're only able to build one package at a time due to a bunch of linear dependencies (in that case, you're getting |
comment:12
And actually, I knew that Meson didn't use Make as its backend, but... it uses Ninja! So they're the same example. |
comment:13
Anyway, thanks for the discussion. It is good that we are aware of the longer term context. We'll see in which direction things move (I predict that more build systems embrace the job server protocol, or improvements of it). To return to the technical point of this ticket: I propose to create a wrapper script in Python that tries to acquire >= A, <= B jobs from the jobserver within <= T wall clock seconds, sets the environment variable |
This comment has been minimized.
This comment has been minimized.
comment:17
Setting new milestone based on a cursory review of ticket status, priority, and last modification date. |
…sm of doctesting <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes sagemath#1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> This is useful when running our doctester in parallel with other build steps, or several doctesters in parallel, as happens for example in `make SAGE_CHECK=yes pypi-wheels`, and more of that after sagemath#35095. To test: ``` MAKE="make -j14" make SAGE_NUM_THREADS=100 DEBUG_JOBCLIENT=1 ptest ``` This will make the doctester attempt to use 100 workers, but it will only get tokens for 14 workers from `make`. `DEBUG_JOBCLIENT=1` shows what's happening. Upstream PR: - milahu/gnumake-tokenpool#3 (merged) <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes sagemath#12345". --> - Resolves sagemath#30369 <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [ ] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - sagemath#12345: short description why this is a dependency - sagemath#34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: sagemath#36640 Reported by: Matthias Köppe Reviewer(s): Michael Orlitzky
The correct way out of the mess with recommending
MAKE='make -j8'
instead ofmake -j8
(which we do because of the outdated GNU make 3.81 on macOS - see #21610, #30345) is to use GNU make's POSIX job server protocol - https://www.gnu.org/software/make/manual/html_node/POSIX-Jobserver.htmlCreate a wrapper script in Python that tries to acquire >= A, <= B jobs from the jobserver within <= T wall clock seconds, sets the environment variable
SAGE_NUM_THREADS
to min(C, NUM_JOBS_RECEIVED), and invokes an arbitrary script.Use this script as a wrapper for the sagelib build and docbuild.
Replace the recommendation
MAKE='make -j8' make
by the familiarmake -j8
.In the top-level
Makefile
, filter out-j
so that also users who continue to follow the old recommendationMAKE='make -j8' make
benefit from the improvements, and to get rid of the "disabling jobserver" messages.CC: @dimpase @orlitzky @jhpalmieri @Etn40ff
Component: build
Issue created by migration from https://trac.sagemath.org/ticket/30369
The text was updated successfully, but these errors were encountered: