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

build: Add the parallel feature, set -j arg based on NUM_JOBS #25

Closed
wants to merge 1 commit into from

Conversation

ParkMyCar
Copy link
Member

This PR speeds up builds of protobuf-src for me from ~5 minutes to ~1 minute.

There's probably a higher level issue that I haven't dug into here yet, the actually cmake command that gets run, without this PR, is:

MAKEFLAGS="-j --jobserver-fds=8,9 --jobserver-auth=8,9" cmake --build . --target install --config Debug

This should parallelize the build with Cargo's jobserver (I think?), but something seems to go wrong and at least locally, after ~30 seconds I only see one instance of clang running.

With this PR the cmake command is updated to:

MAKEFLAGS="-j --jobserver-fds=8,9 --jobserver-auth=8,9" cmake --build . --target install --config Debug -- -j12

Further, looking at the logs from cmake this seems to disable jobserver mode:

[protobuf-src 2.1.0+27.1] make: warning: -jN forced in submake: disabling jobserver mode.

This isn't ideal, but something seems to be going wrong with Cargo's job server which is seriously slowing down builds.

Copy link
Contributor

@def- def- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main concern with just parallelizing a lot is that this can cause OoMs.

I think cmake might just ignore the MAKEFLAGS. How about adding the entire -- -j --jobserver-fds=8,9 --jobserver-auth=8,9 at the end instead?

@def- def- self-requested a review November 14, 2024 22:11
@benesch
Copy link
Member

benesch commented Nov 14, 2024

Hrm, seems like some upstream issues about this:

Not sure what the right fix is, but concur with Dennis that disabling the jobserver and allowing parallelism has led to OOMs in CI during builds in the past.

@petrosagg
Copy link
Contributor

Is there a way to have this for builds on dev machines? It's rare that this crate needs to be rebuilt but not THAT rare, especially if I'm jumping around branches etc

@benesch
Copy link
Member

benesch commented Nov 14, 2024

Is there a way to have this for builds on dev machines? It's rare that this crate needs to be rebuilt but not THAT rare, especially if I'm jumping around branches etc

It's still dicey. We've seen compiling Materialize OOM on dev machines in the past when we haven't been careful to let one single jobserver be responsible for managing all the parallelism.

The jobserver protocol isn't all that complicated. I'm hopeful that it might be possible to track down whatever the root cause here is without too much trouble.

@ParkMyCar
Copy link
Member Author

Concerns about memory usage totally makes sense! I'm going to close this out for now since this PR isn't the right approach, but also I don't have the cycles at the moment to investigate the upstream jobserver issue. As a workaround folks building Materialize can use Bazel which handles this more gracefully.

@ParkMyCar ParkMyCar closed this Nov 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants