Skip to content

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

Draft
emilazy wants to merge 1 commit intoNixOS:stagingfrom
emilazy:push-snznnmvvtxos
Draft

{stdenv,ninja}: add support for NIX_LOAD_LIMIT#328677
emilazy wants to merge 1 commit intoNixOS:stagingfrom
emilazy:push-snznnmvvtxos

Conversation

@emilazy
Copy link
Copy Markdown
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
@emilazy emilazy force-pushed the push-snznnmvvtxos branch from ad969e7 to f76f312 Compare July 20, 2024 15:59
@ofborg ofborg bot added 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. and removed 2.status: merge conflict This PR has merge conflicts with the target branch labels Jul 20, 2024
@philiptaron philiptaron self-requested a review August 1, 2024 20:19
Copy link
Copy Markdown
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.


local flagsArray=(
-j$buildCores
${NIX_LOAD_LIMIT:+-l${NIX_LOAD_LIMIT}}
Copy link
Copy Markdown
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

local flagsArray=(
${enableParallelBuilding:+-j${NIX_BUILD_CORES}}
SHELL="$SHELL"
${NIX_LOAD_LIMIT:+-l${NIX_LOAD_LIMIT}}
Copy link
Copy Markdown
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
Copy Markdown
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
@nixpkgs-ci nixpkgs-ci bot added 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 12.approvals: 1 This PR was reviewed and approved by one person. labels Jun 25, 2025
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 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: stdenv Standard environment 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-darwin-stdenv This PR causes stdenv to rebuild on Darwin and must target a staging branch. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants