Kirk Pepperdine at Java.net's Community Corner 2009
Tuesday afternoon, Kirk Pepperdine presented at java.net's Community Corner, on the topic of performance tuning. Kirk talked about the difficulties you're likely to encounter when you attempt to tune an application.
In one example, Kirk compared two sets of code, one of which needlessly repeated the same
a + b calculation within the loop, while the other applied better logic by computing
a + b first and storing the result in a third variable. How did the performance of the two applications compare? Identical, both applications using 0 seconds. Why? Because the compiler determined that the code in both examples was dead: there was nothing output by the functions in both cases, so the compiler stripped both the inefficient and the more efficient lines of code from the final executable.
The lessons: 1) compiled code that is recognized as doing nothing by the compiler occupies no execution time; 2) sometimes something that seems like it will clearly improve performance makes no difference whatsoever.
In another example, Kirk worked on a component and succeeded at making it more efficient. Running the full system test showed improved performance at lower system loads, but at higher loads the application actually took more time to run than it had before.
Huh? Improving the efficiency of a component can result in the application running slower in some situations? Yes. The reason, in this case, is that the improved component was able to feed its output to the next component in the processing sequence at a higher rate than was the case before. In this particular application, that subsequent component was unable to process efficiently when it received the increased output from the improved component.
Kirk's point is that: performance tuning is application specific. There is no such thing as: "Do this and your application will run faster." This doesn't mean that performance tuning is impossible. It does mean that each application, and each system of applications, is unique. Performance tuning is an art as much as it is a science.
Archives and Subscriptions: This blog is delivered weekdays as
Today RSS feed. Also, once this page is no longer featured as the
front page of java.net it will be
archived along with other past issues in the href="http://today.java.net/today/archive/">java.net Archive.