-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
libstore: change max-jobs
default to auto
#9039
base: master
Are you sure you want to change the base?
Conversation
024f4b6
to
f25f19a
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.
Good to stay in sync with NixOS, which has provided a better out of the box experience with respect to the max-jobs
option.
f25f19a
to
c740ade
Compare
@@ -147,15 +147,14 @@ public: | |||
"the log to show if a build fails."}; | |||
|
|||
MaxBuildJobsSetting maxBuildJobs{ | |||
this, 1, "max-jobs", | |||
this, getMaxThreads(), "max-jobs", |
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.
A default of getMaxThreads()
makes documentation generation non-reproducible. It may be better to represent the "auto" value explicitly, e.g. by changing the type of this option to std::optional<unsigned int>
, with "auto" encoded as std::nullopt
.
c740ade
to
3fb783a
Compare
3fb783a
to
a405bf5
Compare
src/libstore/globals.cc
Outdated
{ | ||
if (str == "auto") return std::max(1U, std::thread::hardware_concurrency()); | ||
return value.value_or(getMaxThreads()); |
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.
return value.value_or(getMaxThreads()); | |
// Settings should be fast to retrieve. Ignore changes to core count - rare, and process lifespan is often short. | |
unsigned int cachedThreads = getMaxThreads(); | |
return value.value_or(cachedThreads); |
Triaged in Nix team meeting 2023-10-13: |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/2023-10-13-nix-team-meeting-minutes-94/34395/1 |
a405bf5
to
43db31d
Compare
43db31d
to
fb4388d
Compare
fb4388d
to
13742f9
Compare
Instead of improving docs reproducibility by changing the type (which I tried but ran into some gnarly template related issues), I decided to extend This latter part would've most likely been necessary either way as we would've wanted some way to render |
const std::set<std::string> & aliases = {}) | ||
: BaseSetting<unsigned int>(def, true, name, description, aliases) | ||
const std::set<std::string> & aliases = {}, | ||
const std::optional<std::string> defaultText = std::nullopt) |
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.
all these constructor parameters should ideally be by value and then std::move
d further. Then the way the caller calls it (with lvalues or rvalues) unnecessary copies can be avoided.
: BaseSetting<Paths>(def, true, name, description, aliases) | ||
const std::set<std::string> & aliases = {}, | ||
const std::optional<std::string> defaultText = std::nullopt) | ||
: BaseSetting<Paths>(def, name, description, aliases, defaultText) |
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.
same here
: BaseSetting<Path>(def, true, name, description, aliases) | ||
const std::set<std::string> & aliases, | ||
const std::optional<std::string> defaultText) | ||
: BaseSetting<Path>(def, name, description, aliases, defaultText) |
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.
ok there are many possibilities to do call-by-value optimizations in constructors here. maybe just leave it as is and i open a pr on that on another occasion.
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.
Oh, maybe... wait, is this meant to be const references to string literals in the code where all the settings are defined, and none of them are dynamic? @Ericson2314
std::optional<ExperimentalFeature> experimentalFeature = std::nullopt) | ||
: AbstractSetting(name, description, aliases, experimentalFeature) | ||
, value(def) | ||
, defaultValue(def) | ||
, documentDefault(documentDefault) | ||
, defaultText(defaultText) |
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.
plz use std::move
here as this is by value
std::optional<ExperimentalFeature> experimentalFeature = std::nullopt) | ||
: BaseSetting<T>(def, documentDefault, name, description, aliases, experimentalFeature) | ||
: BaseSetting<T>(def, name, description, aliases, defaultText, experimentalFeature) |
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.
same here
13742f9
to
6ca89c7
Compare
What's the status of this? I'd really like to see this change deployed to the masses. Thanks for the work so far! |
Oh no, I dropped the ball on this. |
@roberth I'm quite busy lately so I don't have the time to rebase this at the moment, if anyone's interested in picking up this PR, feel free to, otherwise I'll come back to it eventually when I get more time |
Motivation
Non-NixOS users who install Nix will have a poor experience as the default is
1
especially when building derivations with many dependencies.Priorities
Add 👍 to pull requests you find important.