-
-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Optimize Nix build CPU utilization with NIX_MAX_CORES #31965
Conversation
Isn't that the whole point of the setting, to be able to choose? I think that default should be 0, not 1. |
@domenkozar If you mean that |
Sounds OK to me. In particular, that increase in If we go ahead with this, it might be worth to make this value overridable like |
9361fcd
to
769d156
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this, but we should get an opinion of some other member as well, since it's a change in stdenv behavior.
Let me try /cc @edolstra ("code owner" anyway). |
This PR has stalled because it removes the ability to prioritize builds for you, and it is only useful if |
When `build-cores` is less than the number of CPUs, `make -l$NIX_BUILD_CORES` keeps the remaining CPUs unutilized even when `max-jobs` is greater than 1. This is good if you want to dedicate those CPUs to something other than Nix builds, and it is bad if you want to balance `build-cores` with `max-jobs` to maximize utilization of the system without overloading it. To achieve the latter goal `make -l` should be given the optimal load average which is now available in `$NIX_MAX_CORES`. The implementation mirrors Ninja: https://github.com/ninja-build/ninja/blob/e234a7bd/src/ninja.cc#L222-L233 https://github.com/ninja-build/ninja/blob/e234a7bd/src/util.cc#L473-L481
I would like to have this for the 96-core aarch64 builder. We often get into a state where processes cannot fork, and I assume it's caused by occasional load oscillations when many builds fire up to 96 make jobs at once. |
The prioritization is a tiny nitpick. A really proper solution would be via a machine-wide jobserver coordinating this. |
My hypothesis (observed on my hydra) is that aarch64 is flooded by haskell builds that do not respect NIX_BUILD_CORES anyway, and the only temporary solution is to decrease build-max-jobs: #32697 (comment) . I think that a reasonably good solution is to increase |
I don't understand the implications of this PR. What are the semantics of |
@edolstra |
Both parameters limit the parallelism of the build.
When @grahamc and @vcunat consider(ed) setting |
No, this is not right. The code anticipates that Nix might start providing |
Are there any updates on this pull request, please? |
Hello, I'm a bot and I thank you in the name of the community for your contributions. Nixpkgs is a busy repository, and unfortunately sometimes PRs get left behind for too long. Nevertheless, we'd like to help committers reach the PRs that are still important. This PR has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human. If this is still important to you and you'd like to remove the stale label, we ask that you leave a comment. Your comment can be as simple as "still important to me". But there's a bit more you can do: If you received an approval by an unprivileged maintainer and you are just waiting for a merge, you can @ mention someone with merge permissions and ask them to help. You might be able to find someone relevant by using Git blame on the relevant files, or via GitHub's web interface. You can see if someone's a member of the nixpkgs-committers team, by hovering with the mouse over their username on the web interface, or by searching them directly on the list. If your PR wasn't reviewed at all, it might help to find someone who's perhaps a user of the package or module you are changing, or alternatively, ask once more for a review by the maintainer of the package/module this is about. If you don't know any, you can use Git blame on the relevant files, or GitHub's web interface to find someone who touched the relevant files in the past. If your PR has had reviews and nevertheless got stale, make sure you've responded to all of the reviewer's requests / questions. Usually when PR authors show responsibility and dedication, reviewers (privileged or not) show dedication as well. If you've pushed a change, it's possible the reviewer wasn't notified about your push via email, so you can always officially request them for a review, or just @ mention them and say you've addressed their comments. Lastly, you can always ask for help at our Discourse Forum, or more specifically, at this thread or at #nixos' IRC channel. |
This PR seems promising. Is there any chance to be rebased and landed? |
@orivej can you please rebase and fix the merge conflicts? |
I marked this as stale due to inactivity. → More info |
i rebased this in #141266 |
Motivation for this change
When
build-cores
is less than the number of CPUs,make -l$NIX_BUILD_CORES
keeps the remaining CPUs unutilized, even whenmax-jobs
is greater than 1. This is good if you want to dedicate those CPUs to something other than Nix builds, and it is bad if you want to balancebuild-cores
withmax-jobs
to maximize utilization of the system without overloading it. To achieve the latter goalmake -l
should be given the optimal load average which is now available in$NIX_MAX_CORES
.The implementation mirrors Ninja:
https://github.com/ninja-build/ninja/blob/e234a7bd/src/ninja.cc#L222-L233
https://github.com/ninja-build/ninja/blob/e234a7bd/src/util.cc#L473-L481
(
getconf _NPROCESSORS_ONLN
works on Linux and Darwin.)If keeping some CPUs unused is desirable, Nix may add an option and export
NIX_MAX_CORES
with its value for the builder.Things done
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)