Pensieri di un lunatico minore

6 August 2006 Programming

A tale of performance optimization

Some time ago, I was working at a company on a product that was suffering from some performance issues. It seemed that lookups in a specific data-set were taking too long, so the developers were continually discussing new structures for storing things. Then I asked a question: “Why does it matter? How often are you looking it up?”

Turns out it was being looked up hundreds of times per operation. The answer? Look it up at the beginning of the operation, and just hold a local cached copy. Ta’da, a 100x performance boost without complicating the data structure, and the elimination of a mathematical bug if the value of the query changed during the operation—which could happen, but would break the algorithm.

There ends the lesson.

This entry was posted at 10:07 am on 6 August 2006 and is filed under Programming. You can follow any responses to this entry through the post-specific RSS 2.0 feed.

No comments found.

Responses are currently closed, but you can trackback from your own site.