On Thu, 2026-04-16 at 09:20 -0400, Paul Smith wrote:
>
> That is already not supposed to happen. There is an adjustment that
> prevents too many jobs from being started per second, by trying to
> guess what the load average would be at this instant based on the
> last
> value plus any jobs we've started. The goal is to prevent the
> "stampeding horses" scenario especially when GNU Make starts.
>
> Obviously we can't take into account any jobs that were started
> elsewhere, including other instances of GNU Make that may be running
> in
> parallel, so if your build systems use the old-school recursive make
> invocation model instead of the more modern "single make" method, the
> load average computation will be much less accurate.
>
> This does assume that the getloadavg() 1 minute average is being
> updated at least once per second. If that's not happening then the
> current algorithm is not sufficient.
I think emerge already runs make in the new mode, with job tokens.
That last assumption completely fails though. getloadavg() reads
kernel's values, doesn't it?
I'm positive those values get updated every 5 seconds. I think this
interval got introduced about a decade ago. Whatever the actual date,
it is hardcoded here:
$ cat /usr/src/linux/include/linux/sched/loadavg.h
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_SCHED_LOADAVG_H
#define _LINUX_SCHED_LOADAVG_H
/*
* These are the constant used to fake the fixed-point load-average
* counting. Some notes:
* - 11 bit fractions expand to 22 bits by the multiplies: this gives
* a load-average precision of 10 bits integer + 11 bits fractional
* - if you want to count load-averages more often, you need more
* precision, or rounding will get you. With 2-second counting freq,
* the EXP_n values would be 1981, 2034 and 2043 if still using only
* 11 bit fractions.
*/
extern unsigned long avenrun[]; /* Load averages */
extern void get_avenrun(unsigned long *loads, unsigned long offset, int
shift);
#define FSHIFT 11 /* nr of bits of precision */
#define FIXED_1 (1<<FSHIFT) /* 1.0 as fixed-point */
#define LOAD_FREQ (5*HZ+1) /* 5 sec intervals */
#define EXP_1 1884 /* 1/exp(5sec/1min) as fixed-
point */
#define EXP_5 2014 /* 1/exp(5sec/5min) */
#define EXP_15 2037 /* 1/exp(5sec/15min) */
~~/snip/~~