You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/libstore/globals.hh
+29-1Lines changed: 29 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -166,7 +166,6 @@ public:
166
166
R"(
167
167
Sets the value of the `NIX_BUILD_CORES` environment variable in the [invocation of the `builder` executable](@docroot@/language/derivations.md#builder-execution) of a derivation.
168
168
The `builder` executable can use this variable to control its own maximum amount of parallelism.
169
-
170
169
<!--
171
170
FIXME(@fricklerhandwerk): I don't think this should even be mentioned here.
172
171
A very generic example using `derivation` and `xargs` may be more appropriate to explain the mechanism.
@@ -176,6 +175,8 @@ public:
176
175
177
176
The value `0` means that the `builder` should use all available CPU cores in the system.
178
177
178
+
The [`load-limit`](#conf-load-limit) setting can be used to limit the total amount of build parallelism based on system load average.
179
+
179
180
> **Note**
180
181
>
181
182
> The number of parallel local Nix build jobs is independently controlled with the [`max-jobs`](#conf-max-jobs) setting.
@@ -184,6 +185,33 @@ public:
184
185
// Don't document the machine-specific default value
185
186
false};
186
187
188
+
Setting<std::optional<unsignedint>> loadLimit{
189
+
this,
190
+
{ getDefaultCores() },
191
+
"load-limit",
192
+
R"(
193
+
Sets the value of the `NIX_LOAD_LIMIT` environment variable in the
194
+
invocation of builders. Builders can use this value at their discretion
195
+
to dynamically control the amount of parallelism with respect to the
196
+
machine's load average.
197
+
198
+
For instance, a builder could use the value to set the `-l` flag to GNU
199
+
Make. In this case, if the load average of the machine exceeds
200
+
`NIX_LOAD_LIMIT`, the amount of parallelism will be dynamically
201
+
reduced.
202
+
203
+
By default, it is set to the number of cores on the machine.
204
+
205
+
On busy machines where Nix co-exists with other workloads, or where
206
+
build throughput is paramount and memory usage is not a bottleneck, the
207
+
default value may not work as intended. In this case, `load-limit`
208
+
should be set to a higher value, or to `none` to prevent the
209
+
`NIX_LOAD_LIMIT` variable being set at all.
210
+
)",
211
+
{},
212
+
// Don't document the machine-specific default value
213
+
false};
214
+
187
215
/**
188
216
* Read-only mode. Don't copy stuff to the store, don't change
0 commit comments