Skip to main content

Improving Performance

Posted by daniel on January 30, 2004 at 5:00 AM PST

"Before you muck up your program's design to improve its performance, first make sure you have a performance problem and that following the advice will solve that problem."

Update: we've posted Sun's open letter to the Eclipse community and would be interested in your reaction.

You've heard similar advice before. Don't start to optimize until you need to and even then, you may not need to. We link to Brian Goetz's developerWorks article Garbage collection and performance in
Also in Java Today
. Of course, when working towards performance, taking measurements are key, but this article points out how the changes in the JVM have changed optimization strategies over the years.

As Goetz writes, "Performance advice often has a short shelf life". Long held biases and beliefs are hard to let go. Some of the realities from programming in Java in the early days are no longer true. For example, the generational collector "makes object allocation in Java applications significantly cheaper than it is in C, a possibility that many developers at first have difficulty imagining. Similarly, because copying collectors do not visit dead objects, a heap with a large number of temporary objects, which is a common situation in Java applications, costs very little to collect; simply trace and copy the live objects to a survivor space and reclaim the entire heap in one fell swoop. No free lists, no block coalescing, no compacting -- just wipe the heap clean and start over. So both allocation and deallocation costs per object went way down in JDK 1.2."

Think of other techniques you've been taught to use over the years. Goetz concludes "For most applications, explicit nulling, object pooling, and explicit garbage collection will harm the throughput of your application, not improve it -- not to mention the intrusiveness of these techniques on your program design. In certain situations, it may be acceptable to trade throughput for predictability -- such as real-time or embedded applications. But for many Java applications, including most server-side applications, you probably would rather have the throughput."

To repeat the quote from the opening, "Performance advice is by definition reactive -- it is designed to address a particular problem that occurred in a particular set of circumstances. If the underlying circumstances change, or they are simply not applicable to your situation, the advice may not be applicable, either. Before you muck up your program's design to improve its performance, first make sure you have a performance problem and that following the advice will solve that problem."

We also link to an article that asks if reuse still a goal for IT businesses? In The Elusive Search for Business Frameworks in the Journal of Object Technology, Dave Thomas argues that "There is strong resistance to reuse in project driven organizations and in many cases financial disincentives to reducing manpower on an assignment through the introduction of reusable code." His recommendation includes thin frameworks and policy driven behavior.


In today's Weblogs , Srikanth Shenoy leads with ActionForm or DynaActionForm - Making the choice. He writes of the benefits of using DynaActionForms when prototyping an application. Shenoy then provides half a dozen reasons for moving to ActionForms for actual deployment. In the feedback, readers are suggesting that XDoclet can replace the use of the DynaActionForms.

Will Iverson's Great Looking Swing points to the JGoodies demos as examples of nice looking Swing apps. Simon Phipps reminds you that the JDS and LookingGlass Webcast [is] coming (more in Projects and Communities).


In Projects and Communities The Linux community homepage features Robert Clevenger's guide Jump Start your Java development on Linux. His three-part OTN series ( part 1, part 2, and part 3 ) covers installation of the JDK and other tools and creating and running your first Java application.


In today's java.net News Headlines
:

Registered users can submit news items for the href="http://today.java.net/today/news/">java.net News Page using
our news submission
form
. All submissions go through an editorial review by news director
Steve Mallet before being posted to the site. You can also subscribe to
thejava.net
News RSS feed
.


Current and upcoming
Java Events
:

Registered users can submit event listings for the href="http://www.java.net/events">java.net Events Page using our href="http://today.java.net/cs/user/create/e"> events submission
form. All submissions go through an editorial review before being
posted to the site.


Archives and Subscriptions: This blog is delivered weekdays as the
Java
Today RSS feed
. All java.net members can subscribe to the email
updates for the site at the href="https://java-net.dev.java.net/servlets/ProjectMailingListList">
java-net Mailing Lists page. You must be logged in to subscribe
to
the javanet_Daily and javanet_Weekly lists. 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.