in reply to Re: Optimizing into the Weird Zone
in thread Optimizing into the Weird Zone

I don't think approaching "quantum levels of computing" has anything to do with it. Yes, processors are getting smaller, but I don't think that's the problem the orginal poster is hitting.

It's not just that CPU manufacturers are approaching sizes of a single atom, but the way the processor works is no longer easily determined. IIRC, Intel gave up publishing op code timings back with the PII 400--the timings fluxuated so much between runs that there was no point.

Branch prediction, piplining, and now hyperthreading basically make processors into run-time code optimizers. I've studied some hand-optimized ASM compared to the output of GCC, and while the hand-optimized can shave off an instruction or two, it will suffer more if the processor makes a branch misprediction.

So all in all, its better if programmers leave that stuff alone if we can get away with it.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

Note: All code is untested, unless otherwise stated

Replies are listed 'Best First'.
Re: Re: Re: Optimizing into the Weird Zone
by BrowserUk (Patriarch) on Aug 12, 2003 at 15:37 UTC

    I've studied some hand- optimized ASM compared to the output of GCC, and while the hand-optimized can shave off an instruction or two, it will suffer more if the processor makes a branch misprediction.

    That just means the guys that optimised the code generators of the GCC compiler did an excellent job.

    So all in all, its better if programmers leave that stuff alone if we can get away with it.

    I bet everyone who uses the GCC compiler is glad that it's programmers didn't take a hands-off attitude.

    I guess it comes down where in the food chain your code comes. If you know it will always be top predator--consuming memory and cycles--then you can afford to apply no bounds, nor waste effort trying to curtail its appitite. However, if your code needs to live in a competative environment sharing limited resources, and especially if your code lives only part way up the food chain (ie. libraries and modules), then your efforts to limit the consumption by your code will have knock on benefits for every run of every top predator written to use it.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
    If I understand your problem, I can solve it! Of course, the same can be said for you.

      That just means the guys that optimised the code generators of the GCC compiler did an excellent job.

      I bet everyone who uses the GCC compiler is glad that it's programmers didn't take a hands-off attitude.

      Yup. The GCC people work hard so the rest of us don't have to.

      ----
      I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
      -- Schemer

      Note: All code is untested, unless otherwise stated