LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   What does optimizing for size mean? (https://www.linuxquestions.org/questions/linux-general-1/what-does-optimizing-for-size-mean-594909/)

Thaidog 10-26-2007 07:24 PM

What does optimizing for size mean?
 
While compiling my kernel with menuconfig I came across a setting that is:

[]Optimize for size (look out for broken compilers!)

What exactly does this setting do?

Hendronicus 10-26-2007 08:28 PM

I tried it once and it used the -Os flag instead of the usual -O2 flag. From the GCC manpage :
Quote:

-Os Optimize for size. -Os enables all -O2 optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size.
My guess, and it is only a guess, is that those further optimizations are redundancy suppressions and relocation hacks, which is why old (broken) compilers will choke. They won't be able to relocate some of the assembly routines.

Thaidog 10-27-2007 12:38 AM

Quote:

Originally Posted by Hendronicus (Post 2938254)
I tried it once and it used the -Os flag instead of the usual -O2 flag.

Did you see any difference in the performance of the system? I'm using a P4 prescott core that has 1MB of full speed cache... I'm guessing it's ok with -O2 but if you see a difference...

Hendronicus 10-27-2007 03:03 AM

No, not really. I used it for a while but now I'm just back to the regular setting. I think it's really a setting more for embedded kernels than for the desktop. It did make my kernel about ~700K smaller, your mileage may vary. I'll bet the real difference is in module sizes. Loop unrolling and things like that would make them individually larger and sometimes that can add up. I didn't check those, though.


All times are GMT -5. The time now is 06:24 PM.