Gentoo: About “optimizing”

As Linux-Mag points out (Gentoo Optimizations Benchmarked) using gcc optimizations for "omg, teh speed" is not all that practical. Sure, I'll add some compiler flags here and there as long as I am compiling everything anyway but I don't consider that a feature of Gentoo Linux.

I actually prefer Gentoo for the package management and customization via USE flags (even with the headaches that they cause sometimes). :)

10 Comments

  1. duckman says:

    portage may give headaches from time to time but so far I have always been able to fix it. Other package managers I have not been so lucky... :-P

  2. Phil says:

    I was actually surprised that Gentoo fared so much better at some of the tests than Ubuntu. I thought the performance benefit would be miniscule!

  3. Cynyr says:

    gentoo for me is the useflags, and to some extent the cutting edgeness. I alos like that i can help out when i do have some free time, or want an itch scratched.

  4. mv says:

    I also do not see CFLAGS as a "feature" of gentoo. The main feature of gentoo for me are the rolling upgrades.

    Concerning benchmarks, there is always the "don't trust a statistics you haven't faked": Benchmarks of the type cited, especially if the difference lies under a second, mean absolutely nothing. However, the benchmark is right that in fact the optimization flags play almost no role; actually even sometimes giving no -march can be better than gcc's processor specific optimization. This is a very strange phenomenon of the gcc. Depending on the processor you are using, your mileage may vary.

    BUT there are several reasons why you might want to add your own flags anyway.
    First of all, these are security reasons: -D_FORTIFY_SOURCE=2 -Wl,-z,now -Wl,-z,relro makes your system safer with practically no drawback, -fstack-protector has only a slight overhead (with -fstack-protector-all you really have to pay for security...); actually, most distributions use these flags throughout; it is unclear why they are not all the default of gentoo.

    Second reason is disk and memory footprint: -fomit-frame-pointer -fvisibility-inlines-hidden and similar flags hardly increase speed, but why waste space for things which are completely unneeded? (Actually the former flag is almost officially recommended, and the latter can in some cases even avoid unintended symbol collision, i.e. can make a library more stable. Of course, it may also be wrong to use it, for obvious reasons.)

    Last reason, then again, is speed: Especially for multimedia applications, it can be a matter of some flags enabled or not enabled whether the system is fast enough to e.g. record and filter something in realtime. For multi-core systems graphite can make an important difference. And an enormous difference in the speed can be made with -ffast-math: Sure, if the application is well-written you better don't use it, but for applications written by somebody who does not know much about numerics, this can not only improve the speed but even the accuracy of the result. Also -finline-functions: I cannot imagine any good reason why not let the compiler decide which function to inline; the small increase of compile time is not a serious argument.

    As always, there are pros and cons: Just using flags without understanding what you are doing is very dangerous. But on the other hand, very few projects care about using flags which are optimal for them: Project leaders apparently often think it is the administrator's/distribution's task, and conversely, distributions seem to think that the projects should add the appropriate flags, so that finally even flags useful for a project are never added...

  5. NetHawk says:

    Gentoo for me has always been about freedom of choice.

    As far as I'm concerned CFLAGS are a matter of choice, and if someone knows what he is doing, and has an exact idea of what the PC will be doing (e.g. server, video-manipulation etc.) then they just might bring in some speed.

    Then there is the package management, which is a masterwork in freedom of choice on it's own. I've seen a lot of different systems (in the sense of programs used and setup), but, they all were Gentoo. How much more choice can one have? :P

    Well the possibility to work out-of-the-box with cutting-edge (bleeding-edge?) technology makes it just so much more fun for me. I just love to have alpha/beta builds on my system. Just to see what is coming up in future :D

    Well, there is also one more thing that I connect with Gentoo, and that's the community around it.

    So, what is Gentoo about?
    Well for me it's the freedom connected with a wonderful and respecting community.

    Just my 2 cents :D

  6. NetHawk says:

    ^- Got a little carried away. How I wanted to end the post was actually: Because of this freedom, Gentoo users will always look differently on CFLAGS (USE_FLAGS) or any other choice they are presented with. But the beautiful thing is they have the possibility to work with whatever they want, and if someone is trying to gain the last piece of speed out of his system he can try :D
    and those who need security can go for it.
    I see CFLAGS as part of the whole Gentoo project. As a vital part of it actually, since without them a great deal of out freedom of choice wouldn't be possible.

  7. nico says:

    I remember a few centuries ago when I was running Redhat. Installing with rpm never worked and installing from source almost always worked. I only saw Linux as a toy OS. It's thanks to Gentoo that I was able to get rid of Windows.

  8. Jeremy Olexa says:

    Interesting comments here people. I agree with all of you.

  9. rich0 says:

    As others have hinted at, these benchmarks don't get at memory use at all, and that is a big deal in many cases. In my case I have a server that is pretty heavily loaded and it is an older system. Sure, I could upgrade it I guess, but why bother if it works?

    However, it is critical that memory consumption be kept to an absolute minimum.

    I suspect that memory use is going to be a big concern in most use cases, unless a system is built with an overspend on RAM (and that money could have gone into something else if the RAM weren't needed just to hold bloated apps).

  10. fangorn says:

    Gentoo ist about choices.

    I built my Laptop (One installation for daily work and one for testing) completely different from my video cruncher (rock solid system with just X and FVWM "Desktop" with handcompiled media-apps) and my network server.

    If you know what you are doing, Gentoo is a dream.

    And when installing Gentoo, you practically can't avoid learning something. ;-)

Leave a Reply