Gentoo Archives: gentoo-user

From: Rich Freeman <rich0@g.o>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Jobs and load-average
Date: Thu, 16 Feb 2023 14:24:25
Message-Id: CAGfcS_kWOqmqGgT3rEdYXggzCF1WSMfCXvgL2PyynwYqvjuUHA@mail.gmail.com
In Reply to: Re: [gentoo-user] Jobs and load-average by Peter Humphrey
1 On Thu, Feb 16, 2023 at 8:39 AM Peter Humphrey <peter@××××××××××××.uk> wrote:
2 >
3 > I've just looked at 'man make', from which it's clear that -j = --jobs, and
4 > that both those and --load-average are passed to /usr/bin/make, presumably
5 > untouched unless portage itself has identically named variables. So I wonder
6 > how feasible it might be for make to incorporate its own checks to ensure that
7 > the load average is not exceeded. I am not a programmer (not for at least 35
8 > years, anyway), so I have to leave any such suggestion to the experts.
9 >
10
11 Well, if we just want to have a fun discussion here are my thoughts.
12 However, the complexity vs usefulness outside of Gentoo is such that I
13 don't see it happening.
14
15 For the most typical use case - a developer building the same thing
16 over and over (which isn't Gentoo), then make could cache info on
17 resources consumed, and use that to make more educated decisions about
18 how many tasks to launch. That wouldn't help us at all, but it would
19 help the typical make user. However, the typical make user can just
20 tune things in other ways.
21
22 It isn't going to be possible for make to estimate build complexity in
23 any practical way. Halting problem aside maybe you could build in
24 some smarts looking at the program being executed and its arguments,
25 but it would be a big mess.
26
27 Something make could do is tune the damping a bit. It could gradually
28 increase the number of jobs it runs and watch the load average, and
29 gradually scale it up appropriately, and gradually scale down if CPU
30 is the issue, or rapidly scale down if swap is the issue. If swapping
31 is detected it could even suspend most of the tasks it has spawned and
32 then gradually continue them as other tasks finish to recover from
33 this condition. However, this isn't going to work as well if portage
34 is itself spawning parallel instances of make - they'd have to talk to
35 each other or portage would somehow need to supervise things.
36
37 A way of thinking about it is that when you have portage spawning
38 multiple instances of make, that is a bit like adding gain to the
39 --load-average MAKEOPTS. So each instance of make independently looks
40 at load average and takes action. So you have an output (compilers
41 that create load), then you sample that load with a time-weighted
42 average, and then you apply gain to this average, and then use that as
43 feedback. That's basically a recipe for out of control oscillation.
44 You need to add damping and get rid of the gain.
45
46 Disclaimer: I'm not an engineer and I suspect a real engineer would be
47 able to add a bit more insight.
48
49 Really though the issue is that this is the sort of thing that only
50 impacts Gentoo and so nobody else is likely to solve this problem for
51 us.
52
53 --
54 Rich

Replies

Subject Author
Re: [gentoo-user] Jobs and load-average Andreas Fink <finkandreas@×××.de>
RE: [gentoo-user] Jobs and load-average Laurence Perkins <lperkins@×××××××.net>