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

{stdenv,ninja}: add support for NIX_LOAD_LIMIT #328677

Draft
wants to merge 1 commit into
base: staging
Choose a base branch
from

Conversation

emilazy
Copy link
Member

@emilazy emilazy commented Jul 20, 2024

Description of changes

See: NixOS/nix#11143

Untested draft, do not merge, warning warning warning.

Copious previous discussion and events: #174473, #184886, #192447, #192799.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@emilazy emilazy requested a review from Ericson2314 as a code owner July 20, 2024 14:28
@emilazy emilazy marked this pull request as draft July 20, 2024 14:28
@github-actions github-actions bot added the 6.topic: stdenv Standard environment label Jul 20, 2024
@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Jul 20, 2024
Copy link
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

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

Looks pretty straightforward to me after getting a primer on Bash :+ syntax and looking up what -l does for ninja and make.

@@ -10,6 +10,7 @@ ninjaBuildPhase() {

local flagsArray=(
-j$buildCores
${NIX_LOAD_LIMIT:+-l${NIX_LOAD_LIMIT}}
Copy link
Contributor

Choose a reason for hiding this comment

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

From ninja --help:

-l N     do not start new jobs if the load average is greater than N

@@ -1391,6 +1403,7 @@ buildPhase() {
local flagsArray=(
${enableParallelBuilding:+-j${NIX_BUILD_CORES}}
SHELL="$SHELL"
${NIX_LOAD_LIMIT:+-l${NIX_LOAD_LIMIT}}
Copy link
Contributor

Choose a reason for hiding this comment

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

From make --help:

  -l [N], --load-average[=N], --max-load[=N]
                              Don't start multiple jobs unless load is below N.

Comment on lines 874 to +875
NIX_BUILD_CORES="${NIX_BUILD_CORES:-1}"
if ((NIX_BUILD_CORES <= 0)); then
guess=$(nproc 2>/dev/null || true)
((NIX_BUILD_CORES = guess <= 0 ? 1 : guess))
if test "$NIX_BUILD_CORES" -le 0; then
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you can combine these two lines like you've done with NIX_LOAD_LIMIT.

@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: stdenv Standard environment 10.rebuild-darwin: 501+ 10.rebuild-darwin: 5001+ 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild 10.rebuild-linux: 501+ 10.rebuild-linux: 5001+ 10.rebuild-linux-stdenv This PR causes stdenv to rebuild
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants