If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

The Performance Between GCC Optimization Levels

10-13-2012, 08:10 PM

Phoronix: The Performance Between GCC Optimization Levels

For those that have never benchmarked the performance differences between GCC's different optimization levels, here are some recent test results comparing the performance differences when using an AMD FX-8150 processor with GCC 4.7.2.

Comment

Indeed, some optimizations will work better in combination with -march settings. The cache issue will show in benchmarks with highly parallelized workloads (such as web serving or databases with many clients).

Regarding the article, it is interesting how the selection of benchmarks emphasizes floating-point heavy code, since this is what benefits a lot from -O3 (and -Ofast, but this may cause calculations result to be different from what you expect).

Comment

-O2 and -O3 can actually produce massive binary output size increases for not much gain over -Os.

When you compile Mozilla software with -O3, you will get much larger binary size, which actually can make it take longer to load, and make the resulting program take up more space in RAM. I think Mozilla recommends -O2, but I've seen where some distributions use -Os, which doesn't make the binaries much smaller, but can hurt Firefox's score on things like Sunspider or Google's V8 benchmark. (-O3 doesn't help it enough to be worth the cost in load times and additional RAM usage)

Obviously some things benefit so much from -O3 that it becomes worth the tradeoff in longer load times and higher RAM consumption. You can't take that for granted, though.

Yes, there is such a thing as being too aggressive with optimization level. Unfortunately, it's hard to always know when you've gone too far because it varies from program to program. Just use Fedora and be happy. They usually do OK with things like this.

Comment

-O2 and -O3 can actually produce massive binary output size increases for not much gain over -Os.

When you compile Mozilla software with -O3, you will get much larger binary size, which actually can make it take longer to load, and make the resulting program take up more space in RAM. I think Mozilla recommends -O2, but I've seen where some distributions use -Os, which doesn't make the binaries much smaller, but can hurt Firefox's score on things like Sunspider or Google's V8 benchmark. (-O3 doesn't help it enough to be worth the cost in load times and additional RAM usage)

Obviously some things benefit so much from -O3 that it becomes worth the tradeoff in longer load times and higher RAM consumption. You can't take that for granted, though.

Yes, there is such a thing as being too aggressive with optimization level. Unfortunately, it's hard to always know when you've gone too far because it varies from program to program. Just use Fedora and be happy. They usually do OK with things like this.

-O2 -march=native is generally considered to be optimal outside of special cases.