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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

max-substitution-jobs setting #8299

Merged
merged 3 commits into from May 12, 2023
Merged

Conversation

urbas
Copy link
Contributor

@urbas urbas commented May 7, 2023

Motivation

Addresses #3379.

A good example of why max-substitution-jobs is needed is the case where we set max-jobs to 0 to force derivations to be built on remote stores. Unfortunately, this limits the number of concurrent substitutions to 1 (not 0 because there's an extra provision to allow at least 1 substitution goal in the case when max-jobs is set to 0). This slows down substitutions.

Another motivating example is the fact that max-jobs default is set to 1, which means that substitution parallelism will be 1 by default. Again, this unnecessarily slows down substitutions.

Context

Currently the maximum number of concurrent substitutions is determined by the max-jobs setting. This PR is in agreement with issue #3379 and proposed a new setting named --max-substitution-jobs.

Checklist for maintainers

Maintainers: tick if completed or explain if not relevant

  • agreed on idea
  • agreed on implementation strategy
  • tests, as appropriate
    • functional tests - tests/**.sh
    • unit tests - src/*/tests
    • integration tests - tests/nixos/*
  • documentation in the manual
  • documentation in the internal API docs
  • code and comments are self-explanatory
  • commit message explains why the change was made
  • new feature or incompatible change: updated release notes

Priorities

Add 馃憤 to pull requests you find important.

cc: @domenkozar @Mic92

@urbas urbas requested a review from thufschmitt as a code owner May 7, 2023 08:17
@Ericson2314
Copy link
Member

Idea seems good to me!

src/libstore/globals.hh Outdated Show resolved Hide resolved
@roberth roberth added feature Feature request or proposal store Issues and pull requests concerning the Nix store labels May 8, 2023
src/libstore/globals.hh Outdated Show resolved Hide resolved
src/libstore/globals.cc Outdated Show resolved Hide resolved
src/libstore/build/worker.cc Outdated Show resolved Hide resolved
@github-actions github-actions bot removed the store Issues and pull requests concerning the Nix store label May 8, 2023
@roberth
Copy link
Member

roberth commented May 10, 2023

Can see plenty of concurrency with -vvvv --option max-jobs 1, as expected. 鉁旓笍
I'd ask for an automated test, but that would require a disproportionately intricate test setup, to reliably show concurrency.

Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

Code reflects the existing solution pattern and lgtm.

I think speeding up downloads on small machines is a nice achievement for the release notes. Could you add something to doc/manual/src/release-notes/rl-next.md?

Comment on lines +211 to +217
if (goal->jobCategory() == JobCategory::Substitution) {
assert(nrSubstitutions > 0);
nrSubstitutions--;
} else {
assert(nrLocalBuilds > 0);
nrLocalBuilds--;
}
Copy link
Member

Choose a reason for hiding this comment

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

Now that we have the enum, it is better to do a switch here. Note because of some -Werror=... you might need a default: assert(false);

Copy link
Member

Choose a reason for hiding this comment

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

Even better would be something like

nrActiveGoals[goal->jobCategory()]--;

Copy link
Member

Choose a reason for hiding this comment

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

I feel like that bakes in an assumption that resources are independent. Relatively speaking; it's just code, and I think it's all fine.

Comment on lines +238 to +240
bool isSubstitutionGoal = goal->jobCategory() == JobCategory::Substitution;
if ((!isSubstitutionGoal && getNrLocalBuilds() < settings.maxBuildJobs) ||
(isSubstitutionGoal && getNrSubstitutions() < settings.maxSubstitutionJobs))
Copy link
Member

Choose a reason for hiding this comment

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

Also good to use switch and handle each case explicitly.

@edolstra edolstra merged commit 643b8d2 into NixOS:master May 12, 2023
8 checks passed
@urbas
Copy link
Contributor Author

urbas commented May 13, 2023

Code reflects the existing solution pattern and lgtm.

I think speeding up downloads on small machines is a nice achievement for the release notes. Could you add something to doc/manual/src/release-notes/rl-next.md?

@roberth: Added release notes in a separate PR: #8328

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/content-addressed-nix-call-for-testers/12881/214

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or proposal
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

7 participants