* src/job.c (load_too_high): Re-enable Linux /proc/loadavg checks.

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.
This commit is contained in:
Paul Smith 2022-01-19 13:44:22 -05:00
parent aab51f7ef2
commit 15db387f18
2 changed files with 13 additions and 16 deletions

6
NEWS
View file

@ -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

View file

@ -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;