Skip to contentSkip to conversation

Compiling 2.2.19 with -O3 flag

DISCUSSION samson swanson 5 participants 9 messages May 24, 2002

lore
Share & tools
lore
#0 lore raw

hi everyone. [all done for fun]

I compiled 2.2.19 with the -O3 flag. then benched with crafty (chess engine) and it peformed faster in that respect.

I would like to ask when compiling with -O3 flag on a kernel such as 2.2.19, what harm / side effect will I feel later on if any? will i loose speed in other area's?

__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

#1 lore raw
Quoted 3 lines

I would like to ask when compiling with -O3 flag on a kernel such as 2.2.19, what harm / side effect will I feel later on if any? will i loose speed in other area's?

Bench it and see. From my own experience -O3 made the kernel a lot larger and reduced overall performance - in part because the kernel already explicitly figures out what it wants inlined.

Interestingly enough -Os outperformed -O2

#2 lore raw
Quoted 5 lines · Alan Cox

Bench it and see. From my own experience -O3 made the kernel a lot larger and reduced overall performance - in part because the kernel already explicitly figures out what it wants inlined.

Interestingly enough -Os outperformed -O2

Heh, now that is interesting.

Or maybe not - not too long ago I did some tests of the various optimization options in gcc 2.96 or so and found that -O2 generates smaller code in most cases than -Os. -Os also did not perform as good, but I was just testing a few bits of code - nothing as versatile as the kernel.

The end result was I recommend -O2 for both performance and size. Maybe I should retest against the kernel...

Robert Love

#3 lore raw
Quoted 5 lines

Or maybe not - not too long ago I did some tests of the various optimization options in gcc 2.96 or so and found that -O2 generates smaller code in most cases than -Os. -Os also did not perform as good, but I was just testing a few bits of code - nothing as versatile as the kernel.

I've done that test with 2.95 and egcs-1.1.2 (its a while back). I've not check with 2.96, 3.0.4 or 3.1

#4 lore raw
In reply to Robert Love
Quoted 9 lines · In article <1022253543.962.236.camel@sinai> you wrote:
Quoted 5 lines · Alan Cox

Bench it and see. From my own experience -O3 made the kernel a lot larger and reduced overall performance - in part because the kernel already explicitly figures out what it wants inlined.

Interestingly enough -Os outperformed -O2

Heh, now that is interesting.

Not really, -Os implies -O2, cf gcc/toplev.c:

          if ((p[0] == 's') && (p[1] == 0))
            { 
              optimize_size = 1;

              /* Optimizing for size forces optimize to be 2.  */
              optimize = 2;
            }

CIao, Marcus

#5 lore raw
Quoted 3 lines · Marcus Meissner
Quoted 1 line

Heh, now that is interesting.

Not really, -Os implies -O2, cf gcc/toplev.c:

Well, according to Alan -Os outperforms -O2. So either the code is smaller _and_ faster - and that is surely interesting - or the code is _not_ smaller and -Os is a misnomer. Seems interesting to me.

Robert Love

#6 lore raw
In reply to Marcus Meissner
Quoted 9 lines · Robert Love
Quoted 3 lines · Marcus Meissner
Quoted 1 line

Heh, now that is interesting.

Not really, -Os implies -O2, cf gcc/toplev.c:

Well, according to Alan -Os outperforms -O2. So either the code is smaller _and_ faster - and that is surely interesting - or the code is _not_ smaller and -Os is a misnomer. Seems interesting to me.

-Os implies -O2 + additional size-reducing features:

[hch@sb hch]$ grep -r optimize_size /work/people/hch/gcc/gcc | wc -l

    250

[hch@sb hch]$

A bunch of matches are in ChangeLog and most are target-specific, but I guess you got the point..

#7 lore raw
Quoted 8 lines · Christoph Hellwig

-Os implies -O2 + additional size-reducing features:

[hch@sb hch]$ grep -r optimize_size /work/people/hch/gcc/gcc | wc -l

    250

[hch@sb hch]$

A bunch of matches are in ChangeLog and most are target-specific, but I guess you got the point..

I know this...maybe I am not being clear. I realize -Os is a derivate of -O2, but is it not an interesting note if -Os can be as fast (or faster) than -O2 and still generate smaller binaries? That is my point.

If -Os is equivalent in speed to -O2 but also generates smaller objects, then why have -O2? If it does not generate smaller objects (which is what my testing has shown) then it is worthless. Unless it is faster than -O2, like Alan said, in which case then the two options need to rethink themselves ;-)

Robert Love

#8 lore raw
In reply to Marcus Meissner
Quoted 3 lines · Robert Love

I know this...maybe I am not being clear. I realize -Os is a derivate of -O2, but is it not an interesting note if -Os can be as fast (or faster) than -O2 and still generate smaller binaries? That is my point.

I've seen it beeing faster with gcc 2.95. Alan's point was (and I think the explanation is plausible) is that it is faster exactly _because_ it produces smaller code due to the instruction cache behaviour of many current CPUs.