Java Performance Tuning

Java(TM) - see bottom of page

|home |services |training |newsletter |tuning tips |tool reports |articles |resources |about us |site map |contact us |
Tools: | GC log analysers| Multi-tenancy tools| Books| SizeOf| Thread analysers| Heap dump analysers|

Our valued sponsors who help make this site possible
JProfiler: Get rid of your performance problems and memory leaks! 

Training online: Concurrency, Threading, GC, Advanced Java and more ... 

Newsletter no. 11, October 25th, 2001

JProfiler
Get rid of your performance problems and memory leaks!

Modern Garbage Collection Tuning
Shows tuning flow chart for GC tuning


Java Performance Training Courses
COURSES AVAILABLE NOW. We can provide training courses to handle all your Java performance needs

Java Performance Tuning, 2nd ed
The classic and most comprehensive book on tuning Java

Java Performance Tuning Newsletter
Your source of Java performance news. Subscribe now!
Enter email:


Training online
Threading Essentials course


JProfiler
Get rid of your performance problems and memory leaks!


I've extracted the tips from last month's articles together with this months, so there's rather a lot of tips in this month's newsletter, especially since the number of pages coming out with performance related information seems to increase every month. And my backlog of pages older than six months just grows too (I'll add them one day, I promise).

One interesting trend is the number of articles about features new to the 1.4 SDK release, especially the java.nio packages. Also J2EE performance seems to be a predominant feature in many of the articles, no doubt reflecting the amount of money currently being poured into that area of Java, together with the strong crop of books focusing on J2EE/EJB design patterns due out now.

Kirk is back, or rather Kirk's roundup is back. Kirk himself is rather more forward than back. He's currently finding that European I.T. has had rather less of a downturn than the US, which is perhaps unsurprising as it never had quite as strong an upturn in the first place.

And here's my usual reminder to our Japanese readers that Yukio Andoh's translation should be available at http://www.hatena.org/JavaPerformanceTuning/ in a while.

News

Java performance tuning related news.

Recent Articles

All the following page references have their tips extracted below.

(Articles listed in last month's newsletter also have their tips extracted below.)

Links

Tools

Upcoming

Jack Shirazi


Kirk's roundup

The reward for being a road warrior is that I get to visit airports. Though some might dread the trip through the airport, I?ve used the experience to compare how efficiently each of the different designs has solved the problem of moving vehicles, aircraft, luggage, and people. The most interesting aspects are the interfaces that allow traffic to flow between each of the subsystems.

Consider the different sections of the airport that you moved through on your last trip. In just about every airport that I?ve seen, the roadways quickly divide vehicles into one of two groups, those picking up, and those dropping off people. The building is designed to handle this by separating those people departing from those who have just arrived. Inside the building, there is typically a subsystem to handle the three different groups of people who are arriving. At its core is a secured area. Entry to this secured area depends upon where you?re coming from. The more interesting aspect is that people and luggage arriving from International destinations must be vetted before they can be allowed to mix with the general population.

How do I measure efficiency in these systems? I use the old standard of wall clock time to measure two primary use cases. These use cases are: how long does it take for me to get onto a plane after I arrive at an airport; and more importantly, how long does it take me to leave the airport once my flight has arrived. Those of you who are lucky enough to be going to the Olympics this year will be happy to know that I would rate Salt Lake City as one of the most efficient airports in the world.

The Server Side

From The Middleware company, proving that sometimes the simplest answers are best, a question regarding a 1.3 VM running on Solaris which was GCing very 15 seconds. The response was a URL to the Sun reference for HotSpot, http://java.sun.com/docs/hotspot/gc/.

Ever since the arrival of the EJB spec, there have been questions about its performance. Should one use Container Managed Persistence or Bean Managed Persistence; Entity Beans or only Session Beans? Once again, this question of EJB system architecture was raised at The Server Side. One of the options listed was to use stateless Session Beans over data objects. The consensus was that this mix offered the best chance for performance and scalability. This post supports the current trend to remove Entity Beans from existing systems that are not meeting performance requirements. My recent experience was to recommend that Entity Beans be removed from one such system. It was calculated that there would be an 80% reduction in the number of objects created by the system if Entity Beans were dropped. These types of reductions in object life cycle management are needed if the system is to stand a chance of meeting its performance and stability requirements.

The JavaRanch

Javaranch included an interesting discussion on how to performance tune an application that needed to deal with a ResultSet containing 40K Integers. In addition to the interesting interaction that occurred between the moderators and the person who posed the question, there were some useful clues given on how Vectors, ArrayList and other collections grow. In short, it pays to pre-grow your collections.

Another thread saw a participant post a URL to a site containing performance tips. The consensus was that the information on the site, http://www.glenmccl.com/, though interesting was somewhat dated. Though some performance tuning axioms never change, many are a result of the current environment. The push for performance demands that we understand the current environment.

The performance cost of import statements was again queried. Why does no-one ever read earlier threads? Why doesn't the moderator (or someone else) point the message to earlier threads? The answer hasn't changed: there is no runtime cost to import, it is a compiler directive and doesn't exist in the compiled bytecode.

An interesting question was about the difference between the following two calls:

Class stringClass = "".getClass();      //1 
Class stringClass = String.class;       //2 

The original poster was concerned with code size (his overriding concern in an MIDP environment). The second call was 419 bytes more than the first, because it generates a static method which is called for each invocation. Other posters found that the second call was significantly faster to run than the first, mainly because it consisted of a three static instruction sequence at runtime, whereas the first call required a dynamic lookup and getClass() invocation. Speed favors line 2, size favors line 1. And of course if you require the class object more than once, you should cache it (for optimal speed):

static Class StringClass = String.class; 

Finally, an interesting discussion on reusing StringBuffers: it is a good idea, but watch out for the gotcha where the StringBuffer has a larger internal array than is necessary - all the subsequent resulting Strings using that StringBuffer will also have the same larger internal array than is necessary.

JavaGaming.org

At JavaGaming, performance discussions often crop up outside the main performance forum. Unsurprising really, a badly performing game is unplayable. In the networking forum a whole slew of discussions concerned the performance advantage of Extenalizable. The conclusion was that you shouldn't use Externalizable unless absolutely necessary - and in the case of scaled up RMI applications it was absolutely necessary. The discussions also talked about TCP vs UDP. The upshot here was that if you need reliable delivery use TCP, otherwise UDP is faster: implementing your own reliable deliery mechanism while using UDP is a bit pointless.

Back in the performance forum, the -Xincgc crops up several times. The -Xincgc option smooths garbage collection by running more often, but actually takes more CPU resources. Use it if individual GC pause time is more important than overall GC time.

And the last discussion I'm covering concerns drawing images with affine transformations (scaling, rotating, etc). drawImage() with an affine transformation creates temporary images (i.e. garbage). The advice given was that pre-transformed images should be reused to avoid generating garbage in the drawing loop.

Kirk Pepperdine.


Tips I

http://www.onjava.com/pub/a/onjava/2001/09/25/optimization.html
Multiprocess JVMs (Page last updated September 2001, Added 2001-10-22, Author Jack Shirazi). Tips:

http://www.javaworld.com/javaworld/jw-10-2001/jw-1012-deadlock.html
Avoiding synchronization deadlocks (Page last updated October 2001, Added 2001-10-22, Author Brain Goetz). Tips:

http://www.sys-con.com/java/article.cfm?id=1165
The facade pattern for internationalization (Page last updated October 2001, Added 2001-10-22, Author David Gallardo). Tips:

http://www-106.ibm.com/developerworks/ibm/library/i-tuning/?open
Tuning the IBM JVM and Linux (Page last updated May 2001, Added 2001-10-22, Authors Duc Vianney and James Phelan). Tips:

http://developer.java.sun.com/developer/qow/archive/153/index.jsp
Minimizing space taken by HTTP downloads (Page last updated October 2001, Added 2001-10-22, Authors Gary Adams and Eric Giguere). Tips:

http://developer.java.sun.com/developer/Books/J2EETech/ch3.pdf
Rambling discussion of building J.Crew website, in Chapter 3 of "J2EE Technology in Practice" (Page last updated September 2001, Added 2001-10-22, Authors Dao Ren, Dr. Rick Cattell and Jim Inscore). Tips:

http://developer.java.sun.com/developer/JDCTechTips/2001/tt0925.html
Generating integer random numbers (Page last updated September 2001, Added 2001-10-22, Author John Zukowski). Tips:

http://www.javaworld.com/javaworld/javaqa/2001-09/02-qa-0921-double.html
String to double (Page last updated September 2001, Added 2001-10-22, Author Tony Sintes). Tips:

http://www.owlmountain.com/tutorials/NonBlockingIo.htm
Tutorial on non-blocking socket I/O available from JDK 1.4 (Page last updated September 2001, Added 2001-10-22, Author Tim Burns). Tips:

http://developer.java.sun.com/developer/technicalArticles/releases/nio/
The java.nio packages (Page last updated October 2001, Added 2001-10-22, Author John Zukowski). Tips:

http://www.sys-con.com/java/article.cfm?id=1169
Javabean component architecture (Page last updated October 2001, Added 2001-10-22, Authors David Hardin and Mike Frerking). Tips:

http://developer.java.sun.com/developer/technicalArticles/Using/
The logging APIs (Page last updated September 2001, Added 2001-10-22, Author Tom Harpin). Tips:

http://www.sys-con.com/java/article.cfm?id=1160
Local entity beans (Page last updated October 2001, Added 2001-10-22, Author Alex Pestrikov). Tips:

http://www.sys-con.com/java/article.cfm?id=1171
J2EE Performance tuning (Page last updated October 2001, Added 2001-10-22, Author James McGovern). Tips:

http://developer.java.sun.com/developer/Books/EarlyJ2SE/IO.pdf
Shortened version of chapter 2, "I/O", from "Early Adopter J2SE 1.4" (Page last updated October 2001, Added 2001-10-22, Author James Hart). Tips:

http://developer.java.sun.com/developer/Books/EarlyJ2SE/Using.pdf
Shortened version of chapter 5, "Utilities: The Logging Architecture", from "Early Adopter J2SE 1.4" (Page last updated October 2001, Added 2001-10-22, Author James Hart). Tips:

http://www.onjava.com/pub/a/onjava/2001/09/26/load.html
Load Balancing Web Applications (Page last updated September 2001, Added 2001-10-22, Author Vivek Veek). Tips:

http://win-www.uia.ac.be/~s985218/professional/thesis/archief/documenten/Marktoverzicht.doc
Overview of common application servers (announced at http://www.theserverside.com/home/thread.jsp?thread_id=9581). I've extracted the performance related features (Page last updated October 2001, Added 2001-10-22, Author Pieter Van Gorp ). Tips:

Tips II (from last month's newsletter)

http://www.onjava.com/pub/a/onjava/2001/08/22/optimization.html
Catching OutOfMemoryErrors (Page last updated August 2001, Added 2001-10-22, Author Jack Shirazi). Tips:

http://java.oreilly.com/news/javaxslt_0801.html
Tips on using XSLT (Page last updated August 2001, Added 2001-10-22, Author Eric M. Burke). Tips:

http://www.onjava.com/pub/a/onjava/2001/09/18/jboss.html
Implementing clustering on a J2EE web server (JBoss+Jetty) (Page last updated September 2001, Added 2001-10-22, Author Bill Burke). Tips:

http://developer.java.sun.com/developer/J2METechTips/2001/tt0917.html
Making HTTP connections using background threads. (Page last updated September 2001, Added 2001-10-22, Author Eric Giguere). Tips:

http://www.theserverside.com/resources/article.jsp?l=Is-EJB-Appropriate
Deciding whether EJB is appropriate. (Page last updated September 2001, Added 2001-10-22, Author Ed Roman). Tips:

http://www.javaworld.com/javaworld/jw-09-2001/jw-0907-merlin.html
Using nonblocking I/O and memory-mapped buffers in SDK 1.4. (Page last updated September 2001, Added 2001-10-22, Author Michael T. Nygard). Tips:

http://www.javaworld.com/jw-09-2001/jw-0907-rmi.html
RMI performance tuning (Page last updated September 2001, Added 2001-10-22, Author Ashok Mathew and Mark Roulo). Tips:

http://developer.java.sun.com/developer/technicalArticles/Threads/swing/
Multithreaded Swing Applications (Page last updated September 2001, Added 2001-10-22, Author Monica Pawlan). Tips:

http://www.microjava.com/articles/techtalk/display?PageNo=1
Timers and low-level GUI display effects (Page last updated September 2001, Added 2001-10-22, Author Roman Bialach). Tips:

http://www.javareport.com/html/from_pages/article.asp?id=4702&mon=9&yr=2001
Architecting and Designing Scalable, Multitier Systems (Page last updated August 2001, Added 2001-10-22, Author Michael Minh Nguyen). Tips:

http://www.theserverside.com/resources/articles/JSP-Performance/ProJsp.html
Performance chapter (chapter 20) from "Professional JSP 2nd Edition" (Page last updated August 2001, Added 2001-10-22, Author Simon Brown, Robert Burdick, Darko Cokor, Jayson Falkner, Ben Galbraith, RodJohnson, Larry Kim, Casey Kochmer, Thor Kristmundsson, Sing Li, Dan Malks, Mark Nelson, Grant Palmer, Bob Sullivan, Geoff Taylor, John Timney, Sameer Tyagi, Geert Van Damme, Steve Wilkinson). Tips:

http://www-106.ibm.com/developerworks/java/library/j-threads2.html
Reducing thread contention (Page last updated September 2001, Added 2001-10-22, Author Brian Goetz). Tips:

http://www.sys-con.com/java/article.cfm?id=1149
Performance tuning (Page last updated September 2001, Added 2001-10-22, Author James McGovern). Tips:

http://www.sys-con.com/java/article.cfm?id=1133
Techniques to avoid deadlocks (Page last updated September 2001, Added 2001-10-22, Author Mark Dykstra). Tips:

http://www.ddj.com/articles/2001/0109/0109a/0109a.htm
Developing Scalable Distributed Applications (Page last updated August 2001, Added 2001-10-22, Author Mario A. Torres). Tips:

http://www.javaworld.com/javaworld/javaqa/2001-08/01-qa-0817-static.html
Inner classes (Page last updated August 2001, Added 2001-10-22, Author Tony Sintes). Tips:

http://discuss.develop.com/archives/wa.exe?A2=ind0010A&L=DOTNET&P=R28572
Microsoft discussion about csharp garbage collection (the Java clone unsurprisingly has similar issues) (Page last updated October 2001, Added 2001-10-22, Author Brian Harry). Tips:

http://www.sys-con.com/java/article.cfm?id=1135
J2EE design optimizations (Page last updated September 2001, Added 2001-10-22, Author Vijay S. Ramachandran). Tips:

http://www.javaworld.com/jw-09-2001/jw-0914-access.html
Customized high-speed, fine-grained access control (Page last updated September 2001, Added 2001-10-22, Author Wally Flint). Tips:

Jack Shirazi


Last Updated: 2023-02-26
Copyright © 2000-2023 Fasterj.com. All Rights Reserved.
All trademarks and registered trademarks appearing on JavaPerformanceTuning.com are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries. JavaPerformanceTuning.com is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
URL: http://www.JavaPerformanceTuning.com/newsletter011.shtml
RSS Feed: http://www.JavaPerformanceTuning.com/newsletters.rss
Trouble with this page? Please contact us