[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Compiling packages for the standard distribution with -Os instead of -O2



On Thu, May 04, 2006 at 11:54:44PM -0400, Anthony DeRobertis wrote:

> If gcc generally generates faster code with -Os than -O2, then isn't
> that a gcc bug, in that the optimizations enabled by -O2 are incorrectly
> picked?

The problem is, "faster" is not a well-defined term. Faster when? I can
well imagine that -O2 code is faster (maybe a LOT faster) as long as all
of your code fits inside the CPU cache. Cache misses nowadays are very
expensive, so if you have a large cache footprint (do words like GNOME,
KDE, Mozilla ring a bell?), using -Os may improve the overall
performance even when all the code pieces are slower when you benchmark
them individually.

I think someone should come up with exact numbers (performance
regressions vs. actual size reduction) before a decision can be made.
My personal opinion is that there is no single choice that is good for
the whole project; I expect performance-critical things like compression
or stream-processing software (like OpenSSL or web servers) to benefit
from -O2, while desktop environments (GNOME, KDE) may benefit from -Os.

Also worth considering that the kernel still marks the usage of -Os as
experimental because of known gcc breakages in the past. Using -Os on a
large scale may well discover new and interesting compiler bugs.

Gabor

-- 
     ---------------------------------------------------------
     MTA SZTAKI Computer and Automation Research Institute
                Hungarian Academy of Sciences
     ---------------------------------------------------------



Reply to: