Re: gcc -O2 vs gcc -Os performance

Martin J. Bligh
2003-02-06T22:48:49Z

>> 2901299 vmlinux.O2
>> 2667827 vmlinux.Os
>
> Well, Os is certainly smaller.

Yup. I have lots of RAM though, so unless I can see the perf increase
from cache effects, it's not desperately interesting to me personally.
If someone could do similar measurements with a puny-cache celeron chip,
it would be interesting ...

> So I suspect -Os tends to be more appropriate for user-mode code, and
> especially code with low repeat rates. Possibly the "low repeat rate"
> thing ends up being true of certain kernel subsystems too.

Fair enough. I'm not desperately interested in user-land code at the
moment, personally, but gcc is admittedly more general. Maybe we should
compile gcc itself with -Os ;-) Andi (I think) also made the observation
that the garbage-collect size for gcc3.2 may be rather small.

The observation re low repeat rate is interesting ... might be amusing
to do some really basic profile-guided optimisation on this grounds,
take readprofile / oprofile output, and compile the files that don't
get hammered at all with -Os rather than -O2. Given their low frequency
(by definition), I'm not sure that improving their icache footprint will
have a measureable effect though.

M.