Not to rain on anybody's parade, but if you actually look at some code optimizations, specifying your compiler options can
have a very dramatic effect on execution time, particularly between different classes of processor and on specific algorithms, although the larger the piece of code the less likely that a specific optimization will improve performance. The question is whether a desktop user is likely to notice that enhancement, which of course they won't- most users never (or very close to never) max out their processor utilization for an extended period of time, and the only things that do are the occasional encoding or cryptographic task, and even that's stretching it a bit. But that's not the same thing at all as saying there is no difference.
The problem with gentoo is that it promises that it is possible for the mildly techy superuser to get the same kind of performance benefits from rolling their own as somebody who has actually studied the code and used a carefully tuned set of flags for that code and processor
, which of course they can't.
The problem with debian, on the other hand, is that it pretends like there isn't any such difference, which, sorry, there is, particularly on floating point operations between new and old machines, and on very unusual hardware, ie, supercomputers, microcontrollers, etc. For most this will not matter, but... I would hesitate to call it BS.
The bottom line is that precompiled packages are more convenient and therefore more useful to 99% of people out there, but that for the fringe cases- hardcore a/v guys, hardware enthusiasts, embedded developers, researchers, etc- it can and does make more sense to do it yourself.
The gentoo guys say that this flexibility makes gentoo superior- that since it can do what you want it to do AND what they want it to do, that it is better. The Debian guys make the same argument that the windows guys do- that better for most is better for all, and if it's not, go someplace else. I'm not sure I like that any more than I like the almost aggressive indifference of gentoo to the non-fringe-case.
So, to summarize my position: it is better to be able to do something and not need to than not be able to when you need to, and to that end, here is the basic process for building something from source:
- Code: Select all
sudo apt-get source <packagename>
If you're still with me and want to optimize your program, the first thing you want to do is to learn the language its written in- and the assembler language of your system to boot. Gentoo pretends this isn't really all that important, but you need to remember that if you compile it with the same set of flags on anything close to what the Debian team does, its gonna be the same damn 1's and 0's- aka, don't bother.
After that, its the tedious and unrewarding process of analyzing code for opportunities for inlining, loop unrolling, etc, and for processor-specific optimizations- the aforementioned floating point difficulties are a good opportunity. A very nice tool to help you in all of this is Acovea, which can produce very significant performance increases given several days of crunching away- and that's on small bits of code. Plan ahead, and bring lunch- unless you really have gotten this far, in which case you're probably gainfully employed doing this kind of thing, and you should buy lunch and save yourself the trouble of making the sandwich.
Unless you happen to be one of those guys that likes to do all the really tedious, hard stuff yourself, in which case this is how you make a sandwich...