1 |
On Nov 27, 2011 5:12 PM, "Michael Mol" <mikemol@×××××.com> wrote: |
2 |
> |
3 |
> I figure that the optimal number of simultaneous CPU-consuming |
4 |
> processes is going to be the number of CPU cores, plus enough to keep |
5 |
> the CPU occupied while others are blocked on I/O. That's the same |
6 |
> reasoning that drives the selection of a -j number, really. |
7 |
> |
8 |
> If I read make's man page correctly, -l acts as a threshold, choosing |
9 |
> not to spawn an additional child process if the system load average is |
10 |
> above a certain value Since system load is a count of actively running |
11 |
> and ready-to-run processes, you want it to be very close to your |
12 |
> number of logical cores[1]. |
13 |
> |
14 |
> Since it's going to be a spot decision for Make as to whether or not |
15 |
> to spawn another child (if it hits its limit, it's not going to check |
16 |
> again until after one of its children returns), there will be many |
17 |
> race cases where the load average is high when it looks, but some |
18 |
> other processes will return shortly afterward.[2] That means adding a |
19 |
> process or two for a fudge factor. |
20 |
> |
21 |
> That's a lot of guess, though, and it still comes down to guess-and-check. |
22 |
> |
23 |
> emerge -j8 @world # MAKEOPTS="-j16 -l10" |
24 |
> |
25 |
> Was the first combination I tried. This completed in 89 minutes. |
26 |
> |
27 |
> emerge -j8 @world # MAKEOPT="-j16 -l8" |
28 |
> |
29 |
> Was the second. This took significantly longer. |
30 |
> |
31 |
> I haven't tried higher than -l10; I needed this box to do be able to |
32 |
> do things, which meant installing more software. I've gone from 177 |
33 |
> packages to 466. |
34 |
> |
35 |
> [1] I don't have a hyperthreading system available, but I suspect that |
36 |
> this is also going to be true of logical cores; It's my understanding |
37 |
> that the overhead from overcommitting CPU comes primarily from context |
38 |
> switching between processors, and hyperthreading adds CPU hardware |
39 |
> specifically to reduce the need to context-switch in splitting |
40 |
> physical CPU resources between threads/processes. So while you'd lose |
41 |
> a little speed for an individual thread, you would gain it back in |
42 |
> aggregate over both threads. |
43 |
> |
44 |
> [2] There would also be cases where the load average is low, such as |
45 |
> if a Make recipe calls for a significant bit of I/O before it consumes |
46 |
> a great deal of CPU, but a simple 7200rpm SATA disk appears to be |
47 |
> sufficiently fast that this case is less frequent. |
48 |
|
49 |
Here's my experience: |
50 |
|
51 |
I always experience emerge failures on my Gentoo VMs if I use |
52 |
MAKEOPTS=-j>3. Not all packages, but many. Including, IIRC, glibc and gcc. |
53 |
|
54 |
This happens even if I make sure that there's just one emerge job being |
55 |
done. And this happens even if I allocate more vCPUs than -j, on VMware and |
56 |
XenServer alike. |
57 |
|
58 |
I don't know where the 'blame' lies, but I've found myself standardizing on |
59 |
MAKEOPTS=-j3, and PORTAGE_DEFAULT_OPTS="--jobs |
60 |
--load-average=<1.6*num_of_vCPU>" |
61 |
|
62 |
(Yes, no explicit number of jobs. The newer portages are smart enough to |
63 |
keep starting new jobs until the load number is reached) |
64 |
|
65 |
Rgds, |