aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Schmaus <flow@gentoo.org>2023-07-24 16:00:33 +0200
committerSam James <sam@gentoo.org>2023-10-09 20:00:20 +0100
commitde7be7f45ee54e3f789def46542919550687d15e (patch)
tree5bf8e211ba18c7a69d6721ce74ac98f84a4932b6
parentFix: move msg array such that it gets assigned only when needed (diff)
downloadportage-de7be7f45ee54e3f789def46542919550687d15e.tar.gz
portage-de7be7f45ee54e3f789def46542919550687d15e.tar.bz2
portage-de7be7f45ee54e3f789def46542919550687d15e.zip
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@gentoo.org> Closes: https://github.com/gentoo/portage/pull/1072 Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--NEWS4
-rw-r--r--lib/portage/package/ebuild/doebuild.py4
-rw-r--r--man/make.conf.53
3 files changed, 9 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index d04cbaed9..2bd662d6b 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 4d4e674c4..7e95a07c0 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 762de83c4..25893c424 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.