-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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: Add load-limit setting to dynamically control parallelism #6855
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Release X.Y (202?-??-??) | ||
|
||
* Add new `load-limit` setting to control the `-lN` flag of GNU Make. |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -142,6 +142,30 @@ public: | |||||||||
)", | ||||||||||
{"build-cores"}, false}; | ||||||||||
|
||||||||||
Setting<unsigned int> loadLimit{ | ||||||||||
this, | ||||||||||
getDefaultCores(), | ||||||||||
"load-limit", | ||||||||||
R"( | ||||||||||
Sets the value of the `NIX_LOAD_LIMIT` environment variable in the | ||||||||||
invocation of builders. Builders can use this value at their discretion | ||||||||||
to dynamically control the amount of parallelism with respect to the | ||||||||||
machine's load average. For instance, in Nixpkgs, if this value is >0, | ||||||||||
the builder passes the `-lN` flag to GNU Make. In this case, if the | ||||||||||
load average of the machine exceeds `N`, the amount of parallelism will | ||||||||||
be dynamically reduced to 1. | ||||||||||
|
||||||||||
By default, it is set to the number of cores available to Nix. | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Along the lines of #7091 we may want to instead fall back to the |
||||||||||
|
||||||||||
On busy machines where Nix co-exists with other workloads, parallelism | ||||||||||
may not work as intended. For example, consider a 64 core machine whose | ||||||||||
load average is 24 and where Nix is limited to 8 cores. By default, | ||||||||||
`-j8 -l8` will be passed to GNU Make. Since the load average exceeds 8, | ||||||||||
Comment on lines
+162
to
+163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Since we're still in the example where the builder is a Make invocation. |
||||||||||
no parallelism will take place despite the fact that 8 cores are | ||||||||||
available. In this case, `load-limit` should be set to `0` to prevent | ||||||||||
the `-lN` flag from being passed to GNU Make. | ||||||||||
Comment on lines
+165
to
+166
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Setting it to zero won't necessarily prevent it to be passed to Make, that would depend on how a builder is implemented. Right now |
||||||||||
)"}; | ||||||||||
|
||||||||||
/* Read-only mode. Don't copy stuff to the store, don't change | ||||||||||
the database. */ | ||||||||||
bool readOnlyMode = false; | ||||||||||
|
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.
No need to point to a specific implementation, as we'd have to keep track of if that statement is still correct.