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. 15, February 22th, 2002

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

Get rid of your performance problems and memory leaks!

First off, if you feel this site has been useful to you, I encourage you to vote for my book "Java Performance Tuning" in the JDJ readers choice awards. The website is a companion to, and a direct consequence of my book.

Now, on to this month's news. I've added 3 new category pages to the website: tips about load balancing; tips about JDBC connection pools; and tips on using volatile.

The articles keep coming so thick and fast that I can barely keep up. And what an eclectic mixture. We have object tracking and recycling, multicasting, compression, cache management, JDBC, JMS, RMI, Proxy objects, signal handling, and much more. The Dr. Dobbs "Priority Queue" article stands out as one providing predictive capability through mathematical analysis using queueing theory, and throws in priority queues to boot. We have a clutch of webservice articles focusing on performance. I know web services don't necessarily mean Java, but these articles provide useful tips for any coarse grained distributed system. And articles for J2ME have made a strong comeback after having being absent for a while.

Kirk discusses ECperf, covers some interesting discussions, and updates us on airport security. We also have a long list of performance related tools. Normally these come in dribs and drabs, but for some reason I have a sudden flood to add to the resource page this month.

If you feel this newsletter could be useful to a friend, why not forward it to them. Note also that Yukio Andoh's Japanese translation will hopefully be available at in a while.

A note from this newsletter's sponsor

Precise Software revolutionizes J2EE Application Performance
Management with automatic problem detection & correction. Read
our white paper on how to instantly isolate J2EE bottlenecks.


Java performance tuning related news.

Discussion groups


Recent Articles

All the following page references have their tips extracted below.

Older Pages

All the following page references have their tips extracted below.

Jack Shirazi

Kirk's roundup

ECperf is a benchmark used for measuring the performance and scalability of J2EE servers. The benchmark was created under the Java Community Process. ECperf uses a new scaling measurement known as Benchmark Business operations per minute (BBops/min). BBops/min is a count of business transactions and orders that can be carried out in the customer?s domain. With so many benchmarks in existence, why do we need another? One reason is that ECperf is intended to run in any vendor?s environment without the need to change any code. This consistency should lend real meaning to the measurement of BBops. Ed Roman, CEO of The Middleware Company, makes the claim that

This brand new benchmarking service offers vendors an easy and cost-efficient way to verify claims by working through a trusted and credible third party. Because it uses the Sun-endorsed ECperf benchmarking standard, this also makes performance claims both fair and comparable.

Wow! Of course it?s expected that vendors will place the best light on their products, and now we have some means of independently verifying that their technology stands up. So, where are all the results? Of the eleven original members of the ECperf JCP committee, only two studies have been posted (and one of those has been withdrawn). Quoting Sun MicroSystems' Shanti Subramanyam, ECperf Spec lead, "Well I certainly hope that vendors will be publishing ECperf results." Certainly IONA, BEA, and HP have conducted in house tests. Certainly Sybase, Oracle and the others know how well their technology performs. So where are the results? To find out, I did a quick search on BEA?s website using the keyword ecperf. The search turned up two hits. It looks as though BEA's answer is to train customers to perform their own ECperf benchmark. Interesting, I looked through HPs website looking for ECperf results for Bluestone. This search netted a single hit which turns out to be a link to the ECperf home page at javasoft. So, if Sun?s position is that they?d like to see results published, one can only ask, why are vendors not publishing?

Ask any salesman and he?ll tell you that unless the Benchmark shows that you?re the best, the results can only hinder his efforts to sell product. Everyone?s application is different so, should this be the case? Well, more often than not, people inappropriately apply results from standard benchmarks to their application and/or environment. To top it all off, when things don?t work out, they blame the benchmark. The question is, where?s the fault? Is it the benchmark or is it in a poor extrapolation of results. No matter the answer, benchmarks now suffer from a creditability gap. Combine this with the pressure on sales to sell and boom, there goes any hope of seeing many results being published.

On the brighter side, I see ECperf as being a better benchmark. Why? Well one of the knocks against benchmarks is that they do not match real life. Though one could still make this claim with ECperf, its emphasis on performing constant quantities of work and it?s measurement of BBops do offer hope that results from these benchmarks will allow for customers to better extrapolate results into their environment. Now, we will only have to worry about estimating the effects of different hardware configurations.

The JavaRanch

Now lets wander into the saloon at the JavaRanch to begin this month?s roundup. The first question of interest was on how one might monitor the amount of memory that your Java process is using. Though the answer was, unanimously, to use Runtime.getRuntime.totalMemory(), it did come with the following warning: "totalMemory() returns the amount of memory used by the JVM." The total amount of memory used by the JVM is that which the OS has currently allocated. Depending upon high water marks, you may actually be using far less than that amount at any particular time.

Want to know how to scare your DBA? Try closing your DB connections between each JDBC call. Every DBA knows that setting up then tearing down a DB connection is a heavy weight process and so do the authors of the JDBC 2.0 specification. If you look at the JDBC 2.0 specification, you?ll find that it includes a connection caching scheme in JDBCDataSource.

One last note, there was a question regarding variable initialization. Though this topic has been covered before, it keeps surfacing often enough that it is worth the time to review how variables are initialized. All variables are initialized to their default values, null for references, false for booleans, and 0 for numerics. Any initialization code found in a static or class initializer and any constructor will be executed in addition to the default initializations. Thus, there is no need to initialize variables to their default value.

Last month there was a little ripple of noise regarding JDK 1.4 GC. That ripple continues at the performance discussion group hosted at The gamer is looking for even more control over GC. In particular, he wanted to be able to schedule GC on a regular interval. There seemed to be quite a bit of support for this suggestion. Both Jack and myself have tuned a Smalltalk application sever that ran what was known as an epoch GC. This GC was scheduled to run at a regular interval. The result of being able to adjust the run interval was often better performance. So there is some evidence that these guys maybe onto a good thing.

There was a long thread discussing possible solutions to untangling the CPU needs of Flash banners and applet-based games running in the same browser. In the end, there seemed to be no way to throttle back Flash. The only possible solution left was to slow the frame rate down to 25 fps. In the middle of the discussion, there is a very nice tutorial on how to use the JNI to control process priorities in Windows. As further evidence on how long the discussion thread ran, there was also a detailed discussion as to why applet writers still rely on JDK 1.1. From this perspective, it?s clear that Microsoft?s decision not to ship a JVM with Windows is a set back to this group.

Finally, a posting alerted all that there was an article posted at [one of the articles in the tips section too] regarding native compilation. In it, there are pros and cons of using native compilation. In the world of JIT and other types of runtime optimizations, you have to wonder how long it will take before we get over the need to see a file of static machine code. Maybe it begs the question: how long was it before application programmers realized the advantage of writing in a 3GL over assembler? [There's still one or two who haven't seen the light, Kirk -ed.]

The Server Side

There was more discussion of benchmarking at The Server Side. Is it possible to bind a process to a single CPU? Though this is not really a Java question, it does have something to do with tuning. The answer on Linux, Solaris, AIX and Windows is yes. For Windows, this comes with a few third party products. In Solaris, processes can be bound to processor sets. This technique seems mostly useful when one is trying to guarantee a minimum level of service or when one is trying to limit the activities of a CPU hog. I?ll wait for reader response before posting any other platforms that support this sometimes-useful technique.

Here?s a question: "Is it a good idea (in terms of scalability) to store a serialized string of 1MB size in the HTTPSession?" It turns out that the author wants to store a large ResultSet in a stateful session bean (SFSB). One response addresses the question by suggesting that the call be made directly from a Servlet. Though this would shorten the distance between the client and the source, I?m not sure if it would really be enough to overcome the potential performance problems. This does seem to lend itself to a cursor-like Entity bean solution. In the solution, the query is conducted in a stateless session bean (SLSB). The result set is wrapped in an Entity bean. The SLSB passes a handle to the Entity bean back to the client (Servlet) after which successive calls to the Servlet will result in the result set being scrolled through.

Airports revisited

Finally, since I did two successive columns on efficiencies in airports, I thought you might be interested in these two conversations I?ve had with Airport security guards.

As I approach the metal detectors at Ft. Lauderdale International Airport, I am stopped by a security guard and was asked for my boarding card and a picture id. I handed her my passport and boarding card. After flipping through my passport several times, she hands it back to me. This is the conversation that follows:
Security guard: "I need an id with a picture in it"
Me: "But that?s my passport"
Security guard: "It needs to have a picture in it."
Me: "But, all passports have pictures in them"

On an even scarier note, I was entering the C halle of Charles du Gaulle airport while in transit when I encountered their metal detection systems. After I passed through the machine, the lady behind me followed and set off all of the alarms. Now, you?d think that the security people would have reacted. You might even think that the guy standing there with the M-16 would have said something but no, she continues on as if nothing happened. The security people didn?t even look at her. So, I asked the security why they didn?t stop the metal laden lady. I was told by the screener (who was looking at a monitor at the time) that she knew how to do her job and that I should go away!

It?s funny, but I never experienced anything like this pre-September 11th.

Kirk Pepperdine.

Balancing Network Load with Priority Queues (Page last updated December 2001, Added 2002-02-22, Author Frank Fabian). Tips:
Counting object creation (Page last updated December 2001, Added 2002-02-22, Author Heinz M. Kabutz). Tips:
Object recycling part 2 (Page last updated February 2002, Added 2002-02-22, Author Angus Muir and Roman Bialach). Tips:
Multicasting efficiency (Page last updated January 2002, Added 2002-02-22, Author Paul Timberlake). Tips:
NIO (Page last updated February 2002, Added 2002-02-22, Author Daniel F. Savarese). Tips:
Compression in Java (Page last updated February 2002, Added 2002-02-22, Author Qusay H. Mahmoud and Konstantin Kladko). Tips:
Porting to KVM (Page last updated February 2002, Added 2002-02-22, Author Shiuh-Lin Lee). Tips:
Atomic File Transactions, Part 2 (Page last updated February 2002, Added 2002-02-22, Author Jonathan Amsterdam). Tips:
Quality of service for web services (Page last updated January 2002, Added 2002-02-22, Author Anbazhagan Mani, Arun Nagarajan). Tips:
Data expiration in caches (Page last updated January 2002, Added 2002-02-22, Author William Grosso). Tips:
Wrapping PreparedStatement (Page last updated January 2002, Added 2002-02-22, Author Bob Byron and Troy Thompson). Tips:
Webservices SOAP communications overheads (Page last updated January 2002, Added 2002-02-22, Author Leigh Dodds). Tips:
Email summarizing best practices for Promoting Scalable Web Services (Page last updated January 2002, Added 2002-02-22, Author Roger L. Costello). Tips:
Report of how Ace's Hardware made their SPECmine tool blazingly fast (Page last updated December 2001, Added 2002-02-22, Author Chris Rijk). Tips:
JMS vs RMI (Page last updated February 2002, Added 2002-02-22, Author Kevin Jones). Tips:
Proxy code generation (Page last updated February 2002, Added 2002-02-22, Author Paul McLachlan). Tips:
Generating code dynamically (Page last updated February 2002, Added 2002-02-22, Author Norman Richards). Tips:
JMS & JCACHE (Page last updated February 2002, Added 2002-02-22, Author Steve Ross-Talbot). Tips:
Notated keys to access elements of nested Maps. (Page last updated January 2002, Added 2002-02-22, Author Matt Liotta). Tips:
Optimizing Java for intensive numeric calculations (Page last updated January 2002, Added 2002-02-22, Author James W. Cooper). Tips:
OS Signal handling in Java (Page last updated January 2002, Added 2002-02-22, Author Chris White). Tips:
Natively compiled code from Java source (Page last updated January 2002, Added 2002-02-22, Author Martyn Honeyford). Tips:
RMI arguments (Page last updated December 2001, Added 2002-02-22, Author Scott Oaks). Tips:
Choosing an application server (Page last updated January 2002, Added 2002-02-22, Author Sue Spielman). Tips:
Chapter 7, "Object Mutability: Strings and other things" of "Java Platform Performance: Strategies and Tactics." (Page last updated 2000, Added 2002-02-22, Author Steve Wilson and Jeff Kesselman). Tips:
Chapter 8, "Algorithms and data structures" of "Java Platform Performance: Strategies and Tactics." (Page last updated 2000, Added 2002-02-22, Author Steve Wilson and Jeff Kesselman). Tips:

Jack Shirazi

Last Updated: 2023-08-28
Copyright © 2000-2023 All Rights Reserved.
All trademarks and registered trademarks appearing on are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries. is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
RSS Feed:
Trouble with this page? Please contact us