]> git.ipfire.org Git - thirdparty/make.git/commitdiff
* src/job.c (load_too_high): Re-enable Linux /proc/loadavg checks.
authorPaul Smith <psmith@gnu.org>
Wed, 19 Jan 2022 18:44:22 +0000 (13:44 -0500)
committerPaul Smith <psmith@gnu.org>
Sun, 6 Feb 2022 23:46:32 +0000 (18:46 -0500)
Further experimentation shows that my previous thinking that there
was a problem using this was woefully mistaken.  The value generated
by the kernel shows runn*ABLE* processes not runn*ING* processes.
* NEWS: Announce the change.

NEWS
src/job.c

diff --git a/NEWS b/NEWS
index 2f552882bd482d9e5d1240f415180fd208f9d3c5..eba371fa542d9ba36606a20f163aec1037837721 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -55,6 +55,12 @@ https://sv.gnu.org/bugs/index.php?group=make&report_id=111&fix_release_id=109&se
   comparison.
   Implementation provided by Jouke Witteveen <j.witteveen@gmail.com>
 
+* New feature: Improved support for -l / --load-average
+  On systems that provide /proc/loadavg (Linux), GNU make will use it to
+  determine the number of runnable jobs and use this as the current load,
+  avoiding the need for heuristics.
+  Implementation provided by Sven C. Dack <sdack@gmx.com>
+
 * If the MAKEFLAGS variable is modified in a makefile, it will be re-parsed
   immediately rather than after all makefiles have been read.  Note that
   although all options are parsed immediately, some special effects won't
index 9d97fc449feb1628e6b51e656fcc279cc4c49629..3c52074e5e5ae3a8b7988ce2dbe2152b183e82c6 100644 (file)
--- a/src/job.c
+++ b/src/job.c
@@ -1948,12 +1948,13 @@ job_next_command (struct child *child)
 
    On systems which provide /proc/loadavg (e.g., Linux), we use an idea
    provided by Sven C. Dack <sven.c.dack@sky.com>: retrieve the current number
-   of processes the kernel is running and, if it's greater than the requested
-   load we don't allow another job to start.  We allow a job to start with
-   equal processes since one of those will be for make itself, which will then
-   pause waiting for jobs to clear.
+   of runnable processes, if it's greater than the requested load we don't
+   allow another job to start.  We allow a job to start with equal processes
+   since one of those will be for make itself, which will then pause waiting
+   for jobs to clear.
 
-   Otherwise, we obtain the system load average and compare that.
+   If /proc/loadavg is not available for some reason, we obtain the system
+   load average and compare that.
 
    The system load average is only recomputed once every N (N>=1) seconds.
    However, a very parallel make can easily start tens or even hundreds of
@@ -2006,17 +2007,7 @@ load_too_high (void)
 #else
   static double last_sec;
   static time_t last_now;
-
-  /* This is disabled by default for now, because it will behave badly if the
-     user gives a value > the number of cores; in that situation the load will
-     never be exceeded, this function always returns false, and we'll start
-     all the jobs.  Also, it's not quite right to limit jobs to the number of
-     cores not busy since a job takes some time to start etc.  Maybe that's
-     OK, I'm not sure exactly how to handle that, but for sure we need to
-     clamp this value at the number of cores before this can be enabled.
-   */
-#define PROC_FD_INIT -1
-  static int proc_fd = PROC_FD_INIT;
+  static int proc_fd = -2;
 
   double load, guess;
   time_t now;