Gentoo Archives: gentoo-performance

From: Jerry McBride <mcbrides9@×××××××.net>
To: gentoo-performance@l.g.o
Subject: Re: [gentoo-performance] inline considered harmful
Date: Thu, 22 Jul 2004 15:05:50
Message-Id: 200407221106.18968.mcbrides9@comcast.net
In Reply to: Re: [gentoo-performance] inline considered harmful by Bart Alewijnse
1 On Thursday 22 July 2004 02:35 pm, Bart Alewijnse wrote:
2 > I'm curious as to how many of you have considered and tried using -Os
3 > for your programs, and it might even apply to parts of the kernel.
4 >
5 > I'm not kidding. On half of my C++ programs, usually those that deal
6 > with mostly hard processing, there is no discernable difference
7 > between -O2 or -O3 and -Os, except that -Os executables are smaller,
8 > and every now and then a benchmark (though that tends to be 'do
9 > something a lot of times in a row', which of course is mostly a
10 > nonsense benchmark) will turn out faster - I have yet to see a case in
11 > which -Os performs noticeablyworse - and most of the time it's about
12 > the same, although that might just be the sort of things I use C for.
13 >
14 > That code size in itself seems to almost completely balance the
15 > optimisations gcc can do (...not that -Os has no optimisations at
16 > all), especially for what in practice are my small, central object
17 > files gave me a whole new perspective on how much more central the
18 > cache is to speed these days. I think many more programs could
19 > benefit, actually.
20 >
21 > For the heck of it, I just compiled md5 with it standard O3 and with
22 > Os. It made a tiny yet
23 > of 150 to 200 ms in favour of Os. (on a a scale of 26 seconds; I used
24 > kcore, so caching should have had no effect [actually, on a 100MB file
25 > in shm, well within cacheability, O3 was faster, by abotu the same
26 > amont, on a 3 second scale (I did this on a slower processor,
27 > 'course)]) But md5 isn't the best example, as it's data crunching, and
28 > not very complex code. I'ld be amazed if it weren't completely cached
29 > either way - the seven hundred bytes or so in executable size
30 > difference (scale of 13K) saved there aren't the most important ever -
31 > except that can be taken to be purely in code, which is partly the
32 > point.
33 >
34 > So I'm even more interested now. It would amuse me if you would humour
35 > me for a few minutes and compile and run a few of your own C programs
36 > (that don't bottleneck on syscalls or io) with Os, see whether it
37 > makes a difference, and in what direction and magnitude.
38 >
39 > Just for kicks, I just compiled my kernel (2.6.7 ck) with Os. It's a
40 > shame it'd hard to measure the speed difference, but it does knock
41 > 300K (~12%) off its size. I think I'll run it for a while, see what
42 > happens.
43 >
44
45 I've been there, done that and bought the t-shirt... Well... maybe I just
46 looked at the t-shirt....
47
48 Anyway, I tried Os, O2 and O3 on a number of different packages on a gentoo
49 box running on an AMD XP2500 clocked to 2.5ghz. My test results were at best
50 ambigeous and didn't reflect what the main stream purporters of "BIG
51 PERFORMANCE GAINS" with magical compiler settings. At first I thought I was
52 onto something, but then, like yourself figured out that it was mostly "smoke
53 and mirrors". Compiler options are best used to optimized specific
54 applications. Over all use, across an entire linux installation... no one
55 option is better than the other. That's been my observation, shoot me if you
56 wish. :')
57
58 I just run
59
60 CHOST="i686-pc-linux-gnu"
61 CFLAGS="-O2 -march=athlon-xp -fomit-frame-pointer -pipe"
62 CXXFLAGS="${CFLAGS}"
63
64 in /etc/make.conf and forget about the optimization madness...
65
66 Besides, most of the ebuilds specify their own optimization settings
67 anyways...
68
69 Cheers.
70
71
72 --
73
74 ******************************************************************************
75 Registered Linux User Number 185956
76 FSF Associate Member number 2340 since 05/20/2004
77 Join me in chat at #linux-users on irc.freenode.net
78 Buy an Xbox for $149.00, run linux on it and Microsoft loses $150.00!
79 10:49am up 93 days, 13:31, 7 users, load average: 0.02, 0.07, 0.08
80
81 --
82 gentoo-performance@g.o mailing list

Replies

Subject Author
Re: [gentoo-performance] inline considered harmful Bart Alewijnse <scarfboy@×××××.com>
Re: [gentoo-performance] inline considered harmful William Kenworthy <billk@×××××××××.au>