commit:     de7be7f45ee54e3f789def46542919550687d15e
Author:     Florian Schmaus <flow <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 24 14:00:33 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Oct  9 19:00:20 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=de7be7f4

ebuild/doebuild.py: also set --load-average in GNUMAKEOPTS default

In the presence of multiple parallel emerge jobs, i.e., emerge
-j<num>, it is good to limit the overall parallelism in the system via
its load average. This avoids overprovisioning the system with tasks
and losing performance due to an increased number of context switches.

Signed-off-by: Florian Schmaus <flow <AT> gentoo.org>
Closes: https://github.com/gentoo/portage/pull/1072
Signed-off-by: Sam James <sam <AT> gentoo.org>

 NEWS                                   | 4 ++++
 lib/portage/package/ebuild/doebuild.py | 4 +++-
 man/make.conf.5                        | 3 ++-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/NEWS b/NEWS
index d04cbaed99..2bd662d6b1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,10 @@
 portage-3.0.53 (UNRELEASED)
 --------------
 
+Features:
+* GNUMAKEFLAGS: also specifiy "-l $(nproc)", that is, limit by load average,
+  per default.
+
 Bug fixes:
 * bintree: Add another API member (invalid_errors) to allow eclean-pkg to 
suppress
   errors when cleaning invalid binpkgs (bug #900224).

diff --git a/lib/portage/package/ebuild/doebuild.py 
b/lib/portage/package/ebuild/doebuild.py
index 4d4e674c4b..7e95a07c01 100644
--- a/lib/portage/package/ebuild/doebuild.py
+++ b/lib/portage/package/ebuild/doebuild.py
@@ -590,7 +590,9 @@ def doebuild_environment(
             if nproc:
                 mysettings["MAKEOPTS"] = "-j%d" % (nproc)
             if "GNUMAKEFLAGS" not in mysettings and "MAKEFLAGS" not in 
mysettings:
-                mysettings["GNUMAKEFLAGS"] = "--output-sync=line"
+                mysettings[
+                    "GNUMAKEFLAGS"
+                ] = f"--load-average {nproc} --output-sync=line"
 
         if not eapi_exports_KV(eapi):
             # Discard KV for EAPIs that don't support it. Cached KV is restored

diff --git a/man/make.conf.5 b/man/make.conf.5
index 762de83c4a..25893c4243 100644
--- a/man/make.conf.5
+++ b/man/make.conf.5
@@ -934,7 +934,8 @@ threads on the system. In order to avoid excess load, the
 \fB\-\-load\-average\fR option is recommended.
 For more information, see \fBmake\fR(1). Also see \fBemerge\fR(1) for
 information about analogous \fB\-\-jobs\fR and \fB\-\-load\-average\fR options.
-Defaults to the number of processors if left unset.
+If unset, defaults to using the number of processors to limit jobs (and
+load average via GNUMAKEFLAGS).
 .TP
 \fBNO_COLOR\fR = \fI[any string]\fR
 Set to any nonempty string (e.g. "1") to disable color by default.

Reply via email to