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

Distributed build for nixpkgs itself. #208

Closed
junjihashimoto opened this issue Mar 25, 2022 · 4 comments
Closed

Distributed build for nixpkgs itself. #208

junjihashimoto opened this issue Mar 25, 2022 · 4 comments

Comments

@junjihashimoto
Copy link

Is your feature request related to a problem? Please describe.
I think current rules_nixpkgs analyzes the nix expression and builds the derivations serially.

Describe the solution you'd like
Build independent derivations in parallel by bazel's features.

@benradf
Copy link
Member

benradf commented Aug 3, 2023

I think current rules_nixpkgs analyzes the nix expression and builds the derivations serially.

Is this the case? I think Bazel will run the nixpkgs_package repository rules in parallel if it can:
image

Closing for now, but feel free to add more details if I've misunderstood your request.

@benradf benradf closed this as not planned Won't fix, can't repro, duplicate, stale Aug 3, 2023
@junjihashimoto
Copy link
Author

junjihashimoto commented Aug 3, 2023

@benradf When we set derivations for each target, they run in parallel. However, in general, a derivation consists of some derivations. The derivations are managed by nix, so they would not be built by Bazel in parallel.

@junjihashimoto
Copy link
Author

I think that if one derivation can be made into multiple bazel targets, the performance will improve dramatically.

@benradf
Copy link
Member

benradf commented Aug 4, 2023

However, in general, a derivation consists of some derivations. The derivations are managed by nix, so they would not be built by Bazel in parallel.

I see, that makes sense. Thanks for clarifying.

We could pass --max-jobs auto to nix-build to make Nix build the derivations in parallel when Bazel invokes it. The problem with this approach is there is no coordination between Nix and Bazel as to how many threads to use, so we may over-saturate the processor with jobs and make the build slower instead of faster.

I think that if one derivation can be made into multiple bazel targets, the performance will improve dramatically.

That would be a great feature to have, but I think it'll be quite difficult to achieve in general. We would have to somehow parse the top-level derivation and split it into Nix expressions for each component. Given the variety of derivations we might encounter, this won't always be possible.

If Bazel gets support for Cooperative Parallelism, we might be able to leverage that to coordinate thread usage efficiently between Nix and Bazel.

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

No branches or pull requests

2 participants