From: Paul Smith Date: Wed, 19 Jan 2022 18:44:22 +0000 (-0500) Subject: * src/job.c (load_too_high): Re-enable Linux /proc/loadavg checks. X-Git-Tag: 4.3.90~113 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=15db387f18f290702193d0ea1ed64f2408dadaaa;p=thirdparty%2Fmake.git * 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. --- diff --git a/NEWS b/NEWS index 2f552882..eba371fa 100644 --- 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 +* 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 + * 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 diff --git a/src/job.c b/src/job.c index 9d97fc44..3c52074e 100644 --- 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 : 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;