From 34f2477d2ef639a6ceb3243d78aad48df679f893 Mon Sep 17 00:00:00 2001 From: Emily Date: Thu, 18 Jul 2024 12:47:36 +0100 Subject: [PATCH] libstore: add load-limit setting to control parallelism Closes: #7091 Closes: #6855 Closes: #8105 Co-authored-by: Alex Wied --- doc/manual/src/release-notes/rl-next.md | 4 +++ src/libstore/daemon.cc | 2 ++ src/libstore/globals.hh | 30 ++++++++++++++++++- .../unix/build/local-derivation-goal.cc | 4 +++ src/libutil/config-impl.hh | 1 + src/libutil/config.cc | 19 ++++++++++++ src/nix-build/nix-build.cc | 2 ++ tests/functional/load-limit.nix | 8 +++++ tests/functional/load-limit.sh | 23 ++++++++++++++ tests/functional/local.mk | 1 + 10 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 doc/manual/src/release-notes/rl-next.md create mode 100644 tests/functional/load-limit.nix create mode 100644 tests/functional/load-limit.sh diff --git a/doc/manual/src/release-notes/rl-next.md b/doc/manual/src/release-notes/rl-next.md new file mode 100644 index 000000000..869dcb3be --- /dev/null +++ b/doc/manual/src/release-notes/rl-next.md @@ -0,0 +1,4 @@ +# Release X.Y (202?-??-??) + +- Add a `load-limit` setting to control builder parallelism. This has + also been backported to the 2.18 and later release branches. diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc index 6533b2f58..f94c7ae3f 100644 --- a/src/libstore/daemon.cc +++ b/src/libstore/daemon.cc @@ -199,6 +199,7 @@ struct ClientSettings time_t maxSilentTime; bool verboseBuild; unsigned int buildCores; + std::optional loadLimit; bool useSubstitutes; StringMap overrides; @@ -212,6 +213,7 @@ struct ClientSettings settings.maxSilentTime = maxSilentTime; settings.verboseBuild = verboseBuild; settings.buildCores = buildCores; + settings.loadLimit.assign(loadLimit); settings.useSubstitutes = useSubstitutes; for (auto & i : overrides) { diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index 30d7537bd..2a38920d8 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -166,7 +166,6 @@ public: R"( 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. The `builder` executable can use this variable to control its own maximum amount of parallelism. -