Gentoo Archives: gentoo-portage-dev

From: James Cloos <cloos@×××××××.com>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] portage 9999 at commit 2d5e38b495776e5bb2266848a3365667f3ca7233 **SLOW**
Date: Wed, 01 May 2013 06:23:55
Message-Id: m3a9ofp6gn.fsf@carbon.jhcloos.org
1 My typical emerge -upvDN world went up from 10s of minutes to several
2 hours sometime between portage 37f33e9 and 2d5e38b.
3
4 I noticed by way of strace(8) that it access(2)es each ebuild in
5 /usr/portage on each configured overay 10 times. Each.
6
7 It does so in order from the last overlay in PORTDIR_OVERLAY to the
8 first. It is the whole cycle which repeats a total of 10 iterations.
9
10 Seems it would be simpler to do the python equiv of ls */*/*.ebuild
11 in each overlay's top dir, note what ebuilds exist in each overlay
12 in a data structure, and use that. Portage shouldn't worry about
13 any changes which occur in the middle of any single run. (Which
14 is not to claim that it currently does, lest that sentence be
15 misunderstood. :)
16
17 Each access(2) is averaging about 300 or so micro seconds. So about 66
18 miliseconds per ebuild. There are 33728 ebuild files in /usr/portage,
19 so that is about 2226 seconds. Or nearly 40 minutes just wasting time.
20
21 I run it in script(1) these days; /usr/bin/time output for one run was:
22
23 4314.78user 305.06system 5:17:03elapsed 24%CPU (0avgtext+0avgdata 4977056maxresident)k
24 145208inputs+14296outputs (9major+34541240minor)pagefaults 0swaps
25
26 So that is on the order of 20 times as long as it used to take.
27
28 I looked at git log. The depgraph commit (62dbcaa4d873784f1) seems to
29 be the only one in that range which could have an effect. At least at
30 first glance.
31
32 After doing the 7420160 access(2) calls, it read in some from a file
33 (the descriptor was closed by the time a was able to run lsof(8) to see
34 what fd 4 was), seek(2)ing between reads, and then seems to have started
35 doing the 7420160 access(2) calls again. (!) As if once wasn't enough. :^/
36
37 No wonder the first run took 5+ hours.
38
39 (I'm falling asleep at the kbd; I hope I didn't miss any needed edits above.)
40
41 -JimC
42 --
43 James Cloos <cloos@×××××××.com> OpenPGP: 1024D/ED7DAEA6

Replies