"So, the software isn't fast enough...what next?"
While the temptation to "dive in" and have a go at optimization can sometimes be very strong, a bit of planning, preparation and understanding what you are aiming for can provide far better results. In this short series on optimization, I'll try to explain some of the techniques that can make the process of optimization easier, and offer better results at a lower cost.
A good place to start is to understand the reasons why you should and why you should NOT optimize your software.
Why you should not optimize:
- Loss in code maintainability. When you optimize software, you are inevitably going to change something, probably moving from a nice clean, structured design to something a bit more "obscure" that perhaps only one person is ever going to understand (and then only until the next week). Is your code going to be maintainable afterwards?
- Risk of new bugs. By changing your software (perhaps in complicated ways) there is a significant risk of either introducing new bugs, or changing the behaviour of code in subtle ways that affect other parts of the system.
- Physical considerations. Many types of optimizations trade physical attributes (code size, RAM requirements, startup/shutdown time, putting code in different types of memory, etc). Can you afford it?
- Time and effort. How much does it cost to change code? Remember you have to organise the testing, arrange for the appropriate documentation and certification, and deploy the new code as well. What is the risk that you invest lots of effort and then don't get any results?
Why you should optimize:
- there is potential for big gains for small changes
- because changing to alternative hardware can be very expensive
- (or) to make changing to alternative cheaper hardware possible
- because your project fails unless you solve the performance issue.
So, in summary, optimization is often the right choice, but you need to be clear about the risks and costs associated before you start.
Later in the series, we'll look at an optimization process which helps you take the decisions about what to optimize and why, at the same time keeping the risks and costs under control.
Ian
Dr Ian Broster is to run a half-day training session on software optimization at the forthcoming Reliable Software Technologies Conference - Ada Europe 2010.
The conference program is available here. Please register on-line and select Tutorial T5 (I. Broster).
There is a discount for registration before 24th May.
The event takes place on the afternoon of Monday 14th June 2010 in Valencia, Spain.
For more information, or if you are unable to attend on this date and would like to take part in a similar tutorial, please feel free to contact us.