-
Notifications
You must be signed in to change notification settings - Fork 81
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
Gracefuly handle available CPU cores #482
Comments
Agreed, this would be ideal. Not sure if you've seen it already, but there's an open Bazel issue on this topic: Cooperative Parallelism #10443. Essentially we need Bazel to provide some kind of API that we can use to cooperatively share available cores. |
Thanks, yes that issue looks a) very promising and b) very stale 🤣 But bazelbuild/bazel#10443 (comment) made a good suggestion: |
for the time being, is there any way for rules_nixpkgs to honor
https://bazel.build/reference/command-line-reference#flag--repo_env doesn't work either ;-/ |
I think the causality is reversed — you need to set the You can set
|
Is your feature request related to a problem? Please describe.
As described in https://nixos.org/manual/nix/stable/advanced-topics/cores-vs-jobs, and it applies to bazel too, it can happen that you trash your system, or even go into OOM issues, when too many parallel nix derivates are being built. The goal is to reduce this number to the number of total available cores (mind: cgroups (!) in containers), to avoid this. Preferable in a dynamic way.
Describe the solution you'd like
The nix build should be executed with a limited number of available cores. Not sure if this is possible, but a good solution would also make sure that a single nix build will also "consume" multiple action slots in bazel, so bazel also "knows" about the load and does not spawn too many other things in parallel.
Describe alternatives you've considered
In our CI, we hardcode
NIX_BUILD_CORES=2
, but this does not have an effect.Additional context
N/A
The text was updated successfully, but these errors were encountered: