Post

When not to optimize

In .NET, Tech/Hacks on December 3, 2007 by Sid Tagged: ,

So anyway, this compiler group discovers that they no longer have 32K, or 128K, or 512K. Instead, they now have a 4GB virtual address space. “Hey, let’s use a really big hash table!” you can hear them saying, “Like, how about 1 MB table?” So they did. But they also had a very sophisticated compiler technology designed for small and relatively dense hash tables. So the result was that the symbols were fairly uniformly distributed over the 256 4K pages in that 1MB, which meant that every symbol access caused a page fault. The compiler was a dog.

The above snippet is from an article that describes one of the first lessons I learned after I started working as a software engineer and dealing with vast bodies of existing code. Rico Mariani couldn’t have put it any better than when he laid out his “10 Commandments of Performance”:

  1. Measure
  2. Measure
  3. Measure
  4. Measure
  5. Measure
  6. Measure
  7. Measure
  8. Measure
  9. Measure
  10. Measure

This needs to become a habit.


Leave a Reply