Re:Duff's device: do + switch fall-through = loop unrolling
by TimothyFitz on Thursday August 13, 2009 @03:29PM
(#761507)
Or perhaps in this case it's more subtle: code becomes optimized for the wrong thing over time. For example the difference in optimization strategies between netburst pentium 4s and core 2 duos is staggering.
Re:Duff's device: do + switch fall-through = loop unrolling
by joe_the_user on Thursday August 13, 2009 @03:47PM
(#761554)
Hmm,
Great point: not only does optimization cost in understanding and system fragility but it can become stale over time and invisibly so.
If you're working on the application level, testing and segregating optimizations like this seems important. Systems level people would operate differently though ...
When numerous instances of Duff's device were removed from the XFree86 Server in version 4.0, there was a notable improvement in performance.[3] Therefore, when considering using this code, it may be worth running a few benchmarks to verify that it actually is the fastest code on the target architecture, at the target optimization level, with the target compiler.
Optimization without testing is worse then pointless. It's premature and we know that's evil.