Gentoo Archives: gentoo-alt

From: Elias Pipping <pipping@××××××××××××.de>
To: gentoo-alt@l.g.o
Subject: Re: [gentoo-alt] Something is wrong with `file`
Date: Fri, 03 Aug 2007 02:19:40
Message-Id: 20070803021912.GB19727@macbook.local
In Reply to: [gentoo-alt] Something is wrong with `file` by Elias Pipping
1 On Sat, Jul 21, 2007 at 12:42:25PM +0200, Elias Pipping wrote:
2 > Hi,
3 >
4 > I use file(1) on a regular basis and I've come across something really
5 > strange.
6 >
7 > I noticed running `file` on info pages takes *ages*.
8 >
9 > What's confusing, is this: that's not the case with /usr/bin/file.
10 >
11 > % pwd
12 > /usr/share/info
13 > % time /usr/bin/file * > /dev/null
14 > 0.201u 0.018s 0:00.22 95.4% 0+0k 0+0io 0pf+0w
15 > % time ~/Gentoo/usr/bin/file * > /dev/null
16 > 28.371u 0.078s 0:28.56 99.5% 0+0k 0+4io 0pf+0w
17 >
18 > That is a *HUGE* difference. I don't know why that is.
19 >
20 > % /usr/bin/file --version
21 > file-4.10
22 > magic file from /usr/share/file/magic
23 > % ~/Gentoo/usr/bin/file --version
24 > file-4.21
25 > magic file from /Users/pipping/Gentoo/usr/share/misc/file/magic
26 >
27 > I've also compared some more filetypes:
28 >
29 > % pwd
30 > /usr/share/man/man7
31 > % time /usr/bin/file * > /dev/null
32 > 0.034u 0.011s 0:00.04 100.0% 0+0k 0+0io 0pf+0w
33 > % time ~/Gentoo/usr/bin/file * > /dev/null
34 > 1.423u 0.010s 0:01.44 99.3% 0+0k 0+0io 0pf+0w
35 >
36 > % pwd
37 > /usr/share/ri/1.8/system/YAML
38 > % time /usr/bin/file * > /dev/null
39 > 0.024u 0.009s 0:00.03 66.6% 0+0k 0+0io 0pf+0w
40 > % time ~/Gentoo/usr/bin/file * > /dev/null
41 > 0.049u 0.004s 0:00.05 80.0% 0+0k 0+0io 0pf+0w
42 >
43 > % pwd
44 > /usr/include
45 > % time /usr/bin/file * > /dev/null
46 > 0.176u 0.014s 0:00.19 94.7% 0+0k 0+0io 0pf+0w
47 > % time ~/Gentoo/usr/bin/file * > /dev/null
48 > 3.874u 0.026s 0:03.91 99.4% 0+0k 0+0io 0pf+0w
49 >
50 > == what i compiled `file` with ==
51 >
52 > % emerge --info | egrep C\(XX\)\?FLAGS
53 > CFLAGS="-O3 -march=nocona -fomit-frame-pointer -pipe"
54 > CXXFLAGS="-O3 -march=nocona -fomit-frame-pointer -pipe"
55 >
56 >
57 > Kind regards,
58 >
59 > Elias
60 >
61 > PS: I ran the above commands multiple times so that time's output
62 > stabilized.
63 >
64 > PPS: don't be tempted to benchmark in /usr/bin or /usr/lib, because
65 > /usr/bin/file does a lot more work there, splitting up universal
66 > binaries (on x86), hence the benchmarking results become useless.
67 >
68 > PPPS: I've had a look at Apple's patches to file[1], but I couldn't find
69 > one that explains the above behavior.
70 >
71 > PPPPS: I'm attaching the output of
72 > `diff -u /usr/share/file/magic ~/Gentoo/usr/share/misc/file/magic`
73 >
74 > [1] http://www.opensource.apple.com/darwinsource/Current/file-6.2/patches/
75
76 Apparently the issue has *only* to do with the magic file. I compiled
77 file from within the prefix but without portage with the prefix
78 /usr/local. `./src/file` would not work because there's no
79 /usr/local/share/file/magic ( or at least on my machine thee isn't ),
80 so i made a link there to ~/Gentoo/usr/share/misc/file/magic. It worked
81 and it was slow. Now I replaced the link with one to
82 /usr/share/file/magic and all of a sudden it was fast. Switched it
83 back, slow again and so on ( I ran the commands a couple of times to
84 make sure the differences in performance weren't caching-related.
85
86 I still don't quite get the enormous difference but at least I know
87 where to dig.
88
89 % du -h /usr/share/file/magic | cut -f 1
90 352K
91 % du -h ~/Gentoo/usr/share/misc/file/magic | cut -f 1
92 464K
93
94
95 -- Elias