On Optimisation

February 2, 2007

Ah, three days of work wasted because of somebody’s misguided “optimisation”. The optimisation in question involved the removal of a long-running worker thread and replacing it with a Threadpool.QueueUserWorkItem() call. Not only that, it was a call into a hokey third-party Threadpool implementation rather than the .NET one. The Subversion comment was “performance improvement”.

Rather than bang on about how this change obviously wasn’t tested (nothing worked afterwards) or how people should be careful about committing to Trunk, I will talk instead about optimisation.

Before any optimisation is done, there should be a problem. If an area of code is “performant enough” then there is no point in incurring the developing/test/release cost of any optimisation. That cost may be very small for one-person or a small team, but is considerably larger for a large team/multiple region/development stream application. So, the first thing you need is proof that something is actually causing a problem.

Secondly, you need to identify a change and ensure that it represents an improvement. I have lost count of the number of times I have seen people say “Oh, I made that [breaking] change to improve performance”. I will respond: where is your evidence that you improved performance? And even if it did improve performance (1) did performance need improving; (2) you BROKE the environment.

Unfortunately, in 500,000 line systems like the one I’m consulting on at present, a small change in one area of the code can have a massive impact of the final software that goes out of the door. We have four geographic regions, two software “flavours” and all of them use the same code in different but similar ways. So the potential for one small change to screw everything up is magnified by 8 time.

I am coming around to the idea that the NASA approach should be taken for projects over a certain size. Each change should be justified, recorded and signed off.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: