You're not wrong in that a smaller cache is one of the reasons you use Os. The others are disk space and RAM. The basic idea is just that if the binary is smaller, it effectively makes the disk, RAM, and cache all hold more.
See
http://gentoo-wiki.com/Safe_Cflags#Celeron_.28Willamette.29
This is a 1.7 ghz celeron, and the recommended setup is:
Code:
CHOST="i686-pc-linux-gnu"
CFLAGS="-march=pentium4 -O2 -pipe -fomit-frame-pointer"
CXXFLAGS="${CFLAGS}
Also from that page:
Code:
Note that [URL="http://www.gentoo.org/doc/en/faq.xml#optimizations"]-O2[/URL]
is regarded as safer than "-O3", and "-O3" can often be a
counter-productive attempt at optimization. On computers with limited
cache and/or memory, "-Os" may provide better performance in some cases
through smaller binaries, although it is slower when using the OpenSSL
library with small keys (DSA keys with less than 2048 bits on VIA C3-2,
1200 MHz and 64 kb on-die cache).
Cache is one of those things that helps a LOT if you go from 0 to a small amount, but the returns decrease substantially as you add more and more cache. For example, consider the Athlon XP's. The Barton is basically a Tbred-B with 512k on die cache instead of 256k. In many cases, Bartons with higher ratings were outperformed by lower rated Tbred-B's... going from 256k to 512k has a subtle (but sometimes noticeable) effect. Adding more cache just means that less probable portions of the RAM get cached, so the increase in cache hit rate is subtle.
256k is more than enough cache for -Os to not be worth it. The quote above suggests -Os basically in a case where cache is 64k (that's pretty small). 256k is a decent sized cache, and a P4 Celeron at 2.0 ghz is not a weak processor. Sure, it's no C2Q, but it's not bad at all. Nowadays, lots of cache is being added to almost useless levels. The performance increases are becoming infinitessimal from added cache.
I run a number of Athlon XP's still (some Bartons, some Tbred-B's, a few Palominos) and -O2 is faster than -Os.
I wouldn't use -Os on anything newer than a P2 / K62 (and even then I'm not sure it would benefit you... but I'd have to test) unless they were very low on RAM or disk space.
Os rarely has any uses now. It was more useful some years back when there were still a lot of 64k cache cpu's lying around.