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