Article 6JX1M CodeSOD: Climbing Optimization Mountain

CodeSOD: Climbing Optimization Mountain

by
Remy Porter
from The Daily WTF on (#6JX1M)

"Personal Mountains" was hearing dire rumors about one of the other developers; rumors about both the quality of their work and their future prospects at the company. Fortunately for Personal Mountains, they never actually had to work with this person.

Unfortunately, that person was fired and 30,000 lines of code were now Personal Mountains' responsibility.

Fortunately, it's not really 30,000 lines of code.

list.DeleteColumn(61);list.DeleteColumn(60);list.DeleteColumn(59);list.DeleteColumn(58);list.DeleteColumn(57);list.DeleteColumn(56);list.DeleteColumn(55);list.DeleteColumn(54);list.DeleteColumn(53);list.DeleteColumn(52);list.DeleteColumn(51);list.DeleteColumn(50);list.DeleteColumn(49);list.DeleteColumn(48);list.DeleteColumn(47);list.DeleteColumn(46);list.DeleteColumn(45);list.DeleteColumn(44);list.DeleteColumn(43);list.DeleteColumn(42);list.DeleteColumn(41);list.DeleteColumn(40);list.DeleteColumn(39);list.DeleteColumn(38);list.DeleteColumn(37);list.DeleteColumn(36);list.DeleteColumn(35);list.DeleteColumn(34);list.DeleteColumn(33);list.DeleteColumn(32);list.DeleteColumn(31);list.DeleteColumn(30);list.DeleteColumn(29);list.DeleteColumn(28);list.DeleteColumn(27);list.DeleteColumn(26);list.DeleteColumn(25);list.DeleteColumn(24);list.DeleteColumn(23);list.DeleteColumn(22);list.DeleteColumn(21);list.DeleteColumn(20);list.DeleteColumn(19);list.DeleteColumn(18);list.DeleteColumn(17);list.DeleteColumn(16);list.DeleteColumn(15);list.DeleteColumn(14);list.DeleteColumn(13);list.DeleteColumn(12);list.DeleteColumn(11);list.DeleteColumn(10);list.DeleteColumn(9);list.DeleteColumn(8);list.DeleteColumn(7);list.DeleteColumn(6);list.DeleteColumn(5);list.DeleteColumn(4);list.DeleteColumn(3);list.DeleteColumn(2);list.DeleteColumn(1);list.DeleteColumn(0);

Comments in the code indicated that this was done for "extreme optimization", which leads me to believe someone heard about loop unrolling and decided to just do that everywhere there was a loop, without regard to whether or not it actually helped performance in any specific case, whether the loop was run frequently enough to justify the optimization, or understanding if the compiler might be more capable at deciding when and where to unroll a loop.

Within a few weeks, Personal Mountains was able to shrink the program from 30,000 lines of code to 10,000, with no measurable impact on its behavior or performance.

proget-icon.png [Advertisement] Keep the plebs out of prod. Restrict NuGet feed privileges with ProGet. Learn more.
External Content
Source RSS or Atom Feed
Feed Location http://syndication.thedailywtf.com/TheDailyWtf
Feed Title The Daily WTF
Feed Link http://thedailywtf.com/
Reply 0 comments