To ensure a successful optimization project, here are three vital things that you might not have thought about before.
- Good information
- Worst case focus
- Project planning
Let's look at these briefly before we return to them later in more detail.
- Good Information: In embedded programming, it's notoriously difficult to see what's actually going on. Yet, to avoid wasting your time during an optimization project, you need to know precisely where the problems are, what the gain is and when to stop.
In the embedded world, it's especially hard to measure how long things take to run. Before long, it's easy to get lost in a maze of interrupts, context switches, measurement errors, overheads and data logging issues. Of course, these are issues that we now know how to handle; with a bit of good tool support, getting good information can be an automatic process.
- Worst cases focus: If your aim is to reduce your execution time budget (without reducing your reliability!) then you need to ensure that your longest times fit into the timing budget regardless of what your average case times do. The average case times are irrelevant.
To put it another way: if you spend time optimizing your most frequently executed code, but which is not on the worst case path, then you're wasting your time; the longest execution time hasn't changed significantly so the timing budget for that application cannot be reduced.
- Project planning: If you were going to add a feature to a product, where do you begin? Clearly, you begin with some project planning: objectives, times, costs, risks. You don't begin at the source code.
If you embark on an optimization project to change the implementation of a feature, use the same project management discipline. Don't dive in head first; instead, think about your objectives, how much it's going to cost, the risks, and so on.