Search code examples
performanceoptimizationlanguage-agnostic

What is the most ridiculous pessimization you've seen?


We all know that premature optimization is the root of all evil because it leads to unreadable/unmaintainable code. Even worse is pessimization, when someone implements an "optimization" because they think it will be faster, but it ends up being slower, as well as being buggy, unmaintainable, etc. What is the most ridiculous example of this that you've seen?


Solution

  • On an old project we inherited some (otherwise excellent) embedded systems programmers who had massive Z-8000 experience.

    Our new environment was 32-bit Sparc Solaris.

    One of the guys went and changed all ints to shorts to speed up our code, since grabbing 16 bits from RAM was quicker than grabbing 32 bits.

    I had to write a demo program to show that grabbing 32-bit values on a 32-bit system was faster than grabbing 16-bit values, and explain that to grab a 16-bit value the CPU had to make a 32-bit wide memory access and then mask out or shift the bits not needed for the 16-bit value.