Slashdot Mirror


Optimizations for Source-Based Distributions?

Kenny Mann asks: "I currently run a Linux distribution called Lunar Linux and it is a source based distribution branched from the original Sorcerer GNU Linux. I've done a bit of research on compiler optimizations and such and was wondering what kind of performance is there really to be had for setting these options? I know that the more options the greater chance of unexpected failures, so my next question is what about optimizing your kernel?" Optimization is tricky, and I think the answer to this question is more complex than "yes, optimize" or "no, don't optimize". Rather there might be classes of applications that are safe to optimize and classes of applications that are not. How do those performance hounds out there feel about optimizing the kernel, however?

4 of 41 comments (clear)

  1. And so I'm not a complete jerk.... by Anonymous Coward · · Score: 3, Informative

    This thread on forums.gentoo.org discusses to death what compilation flags are good to use (mostly gcc 3.x+). Even though you're using a different source based distro, the concepts are all the same.

  2. Re: Should be a database with this info. by OldMiner · · Score: 5, Informative
    to find out what instabilities happen due to specific optimizations, and either fix GCC so it can more intelligently tell when to optimize and when not to

    Having only but read the man page for gcc a couple of times, and not even that of gcc 3.0, I can say I'm woefully underqualified to comment on the subject, but I will anyhow. From what I've observed, there is no legal C++ code that doesn't self-modify which gcc can't intelligently optimize without problems. The only time that I have ever seen optimization issues was when inline assmebler was involved, which I would hope was already optimized, considering the nature of the beast. Further, many of the optimizations that gcc performs are rather simple things such as loop unrolling, function inlining, delaying popping of the stack until after several function calls, etc.

    Perhaps one of the most notable optimizations, for the beginner at least, is that one needs to provide -O or gcc will not allocate any variables in a register. It'll be memory, register, operation, and back to memory over and over again. (Or perhaps just a direct memory operation if you're on x86.) Despite my early teachers' insistance that compilers were simply too smart and didn't need such hints, I tested and found that a trivial heavily looped programs often ran 3 times faster when I declared the loop counters as 'register'. The problem was that we were simply using "gcc source.c" to compile our programs. gcc produces very poor code if -O isn't used at least.

    But, anyhow, I think the largest issues would be concerned with -m and -f flags which may change default or even standard behavior. For instance, -felide-constructors breaks ANSI C++ compliance, but isn't a bad idea if you create and destroy a large number of expernsive objects. (Then again, you shouldn't do that.)

    --
    You like splinters in your crotch? -Jon Caldara
  3. General approach by SpaceLifeForm · · Score: 4, Informative
    1. Don't worry about the kernel, it's pretty tight already. Definitely compile it for your proper platform, but I would not waste time on additional tweaks.

    2. Do re-compile your C library however. Most of your applications spend a lot of their time executing code from the C library.

    --
    You are being MICROattacked, from various angles, in a SOFT manner.
  4. Recent discussion on lkml by heatmzr · · Score: 3, Informative

    gcc optimzations for the kernel were discussed recently on this thread