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

Support make jobserver protocol #71

Open
rossburton opened this issue Apr 14, 2021 · 6 comments
Open

Support make jobserver protocol #71

rossburton opened this issue Apr 14, 2021 · 6 comments
Labels
extension Request for feature not present in ninja

Comments

@rossburton
Copy link

GNU Make has a neat feature called the jobserver protocol, where the top-level Make can allocate a specific number of job slots, and child makes can take slots to do work in. This was designed to stop the parallelisation problem where a top-level make -j10 may potentially spawn 10 separate sub-makes all with -j10 so there's now 100 parallel jobs.

However, it's also useful for resource control is systems which built multiple pieces of software at once. For example, Bitbake can build N different pieces of software at once, and each of those is passed a -jM flag. If each of these N tasks is compiling then thats's N*M jobs so you don't want N or M to be too high, but if only 1 of N is building then you want M to be high.

With the job server protocol there are N slots in total for all sub makes, so you can control the resource utilisation more accurately. If Samurai also supported the jobserver protocol instead of just -j then it could join in the resource pooling and builds can be more efficient.

The canonical implementation of jobserver is in the GNU Make sources. The documentation is pretty vague as it is considered an implementation detail, but it hasn't changed in 20 years... The prototype BitBake support for a master jobserver queue is at http://git.yoctoproject.org/cgit.cgi/poky-contrib/commit/?h=rpurdie/wipqueue4&id=d66a327fb6189db5de8bc489859235dcba306237

@rossburton
Copy link
Author

cc @rpurdie

@michaelforney michaelforney added the extension Request for feature not present in ninja label May 5, 2021
@bonzini
Copy link
Contributor

bonzini commented Mar 26, 2022

Hi, I have done a quick and dirty implementation (less than 200 lines of code) but it uses pthreads. Should I submit a pull request or should I first try to rework it without threads?

@michaelforney
Copy link
Owner

@bonzini, I am interested in taking a look at what you've got, but I'd definitely prefer an implementation without threads.

@eli-schwartz
Copy link

BTW since https://git.savannah.gnu.org/cgit/make.git/commit/?id=7ad2593b2d2bb5b9332f4444d8bf93ac6f958bc6 GNU make supports named pipes as an alternative to anonymous pipes.

Once it actually gets into a release that should be pretty nifty.

@mid-kid
Copy link

mid-kid commented Jan 31, 2023

I feel it's worth noting that gcc picks up on this jobserver when using gcc -flto for LTO builds, and as such is very useful for speeding that up. Using -flto=n to specify the amount of LTO linking jobs isn't great when it comes to projects linking multiple programs concurrently. Oh, and -flto=n still prefers using a jobserver if available.

@bonzini
Copy link
Contributor

bonzini commented Apr 19, 2024

@bonzini, I am interested in taking a look at what you've got, but I'd definitely prefer an implementation without threads.

I opened a new PR in #104 now that someone reminded me of it. It does use threads, which is almost mandatory because the GNU Make protocol requires a blocking file descriptor. But the implementation is quite nifty if you ask me. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension Request for feature not present in ninja
Projects
None yet
Development

No branches or pull requests

5 participants