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|

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

Newsletter no. 8, July 20th, 2001

JProfiler
Get rid of your performance problems and memory leaks!


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:



JProfiler
Get rid of your performance problems and memory leaks!


The performance tuning articles published over the last month emphasize where the focus in Java is today. The majority of articles have looked at performance for the enterprise web server, considering design patterns, J2EE, servlets and dynamic web pages.

Smaller in number but still significant is the set of articles looking at performance for embedded Java applications. In addition, we have some interesting articles on fundamentals of Java performance including synchronization and the WeakHashMap. And finally, we seem to be getting one article each month that is targetted at Java games programming: this month the VolatileImage class from SDK 1.4 is covered.

This month Kirk tells us about discussions on writing a test harness, performance tuning an applet, the performance of sin and cos, serialization performance, Java's productivity, stateless session beans and clusters, and much more. We also get that promised update on his bananas, and a tour de force on the Tour du France (I just couldn't resist that).

Finally 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 week or so.

News

Java performance tuning related news.

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

The 88th running of cycling?s crown jewel: the Tour du France is now well underway. The cyclist with the shortest accumulated time over 20 stages (or individual races) that lead 209 elite athletes through France, is awarded the highly coveted yellow jersey also known as the "golden fleece". Each day of the 3450 km race brings the challenge to remain ahead of the sweeper, a van with a broom attached to it that picks up the stragglers when they fall too far behind the race leaders.

Many riders end their tour after desperately struggling to stay ahead of the sweeper as they climb the Alps or the Pyrenees. Over the years, the drive for performance has changed the nature of the race. Long gone are the days when participants were forbidden to accept assistance. The drive for performance then forced participants to carry a redundant system (a second bicycle) on their backs. In the modern version, cycling?s star performers are supported by team vehicles, domestics, and team mechanics. It is the domestics? responsibility to shuttle food and water to the team?s leaders. If a star's bicycle fails, the domestic will surrender his and then wait for the team vehicle.

Overall time is not the only metric. The tours best sprinter is awarded the green jersey. The tour's best climber is awarded the coveted red and white polka dotted jersey. In the midst of the chaos that surrounds each days race, cycling?s heros provide us with insight into the effort and resources needed to support peak performances. Last year Lance Armstrong rode the 3630 km course in a time of 92.33.08. This works out to an average speed of 39.2 km/hr. Now that?s what I call performance.

On now for this months look at the Java Ranch (www.javaranch.com). A question asked was: can you specify tuning parameters in the Java Plug-in Control Panel that affect CPU and I/O? Though no one answered that question, it is interesting to note that the -X parameters can be set in the control panel. With these, you can tune things such as heap size, gc, etc.

One of the bartenders is writing a test harness and was asking questions about how to log. His idea was to create channels from large StringBuffers. Thoughts from respondents included that the item be handed off to some asynchronous thread, process, or server to complete the logging. It was pointed out that one should avoid situations where the harness may interfere with your timings. Another interesting suggestion was to predefine event types and then just write event codes instead of text messages.

Onto Java Gaming at www.javagaming.org where we find our own Jack, performance tuning an applet for a developer in the thread JavaGaming.Org Message Board: Performance Tuning: Profilers: HPROF. The density of information in this thread is such that I don?t feel it can be summarized. I strongly recommend that you check it out for yourself. The thread included coverage of -Xprof, the HotSpot profiler, and how it differs from -Xrunhprof; what might or might not get inlined; what to target when tuning loops; and more.

In another thread, a developer was concerned about the amount of memory that was being used. It was 3x more than a similar application written in C. The response was that Java is lazy about reclaiming memory and that one could use System.getFree() and System.totalMemory() to determine the real footprint. These numbers could be used to constrain the heap size of the application.

One final thread for those looking to future technologies concerned Java processors. ARM is developing a Java processor named Jazelle. For further information, check out http://www.arm.com/news.ns4/iwpList125/999E8BF064E2783580256A2A0044A3E0?OpenDocument&style=Press_Room.

Also at Java Gaming, but in the "2D Graphics Programming " discussion group brather than the "Performance" discussion group, was a long thread about performance when using sin and cos functions. The basic advice was to use look up tables rather than on the fly calculations, or even re-write the routines to avoid trig functions if possible. But more interesting was a long explanation of possible performance trade-offs, written by Sun's JDK math expert and posted in the thread. Once again, this is too dense to summarize, so you might want to check the thread out directly: JavaGaming.Org Message Board: 2D Graphics Programming in Java: Other Stuff: Sin and Cos .

Finally, lets check out the Middleware Company at www.theserverside.com. The first thread that I pulled up presented an interesting problem. A developer asked why serializing a string was significantly faster than serializing his own custom class (which in this case were almost identical). A participant responded with a nice concise answer which, when implemented, resulted in a 20x speed up. That answer was that the default implementations of the readObject and writeObject methods use reflection. By overriding these methods, you can eliminate the need to use reflection that will net a nice performance improvement.

On a related thread, the question was: to clone or serialize? In the end, a respondent answered that when benchmarking, he found serialization to be much slower than cloning. I found this result surprising until I looked through the source for Object and found the declaration

protected native Object clone() throws CloneNotSupportedException.

Mystery solved.

Once again, the C++ vs. Java question was asked. Many of the thoughtful responses questioned the ability for a large project to contain the many problems (such as classical memory leaks) when using C++. In the end C++ is faster but, if your application does a lot of DB access, is that extra speed noticeable? The current rule of thumb is that people are 4 times faster deploying in Java then they are in C++. I?ll take a performance penalty for an increase in productivity of that magnitude any day.

Another question centered on the use of static objects in Stateless Session Beans running in a Weblogic cluster. A WebLogic cluster is a group of WebLogic EJB servers that can communicate and stay in sync with each other. A stateless session bean is an EJB that does not carry any client or session specific state and is equally sharable by each and every client. Thus the fact that this developer was suggesting that he was carrying state in the stateless session bean is a violation of the EJB specification. Curiously enough, he was wondering why that state did not get replicated to the other servers. The Server Side seems to have a lot of coverage of WebLogic clusters. I?ll spend more time covering EJB servers in future editions of this column.

And finally, as promised, here is the report on my Oronoco bananas. After the initial burst, the growth rate did slow. Last week, I removed about 8 kgs of bananas from the tree. The finger sized bananas look like mini versions of the traditional store bananas. The taste is slightly heavier and much sweeter. I am looking forward to my next bunch.

Kirk Pepperdine.


Tips

http://www.onjava.com/pub/a/onjava/2001/07/09/optimization.html
Using the WeakHashMap class (Page last updated June 2001, Added 2001-07-20, Author Jack Shirazi). Tips:

http://www-106.ibm.com/developerworks/java/library/j-threads1.html
When synchronization is required (Page last updated July 2001, Added 2001-07-20, Author Brian Goetz). Tips:

ftp://ftp.java.sun.com/docs/j2se/1.4/VolatileImage.pdf and http://www.javagaming.org/Docs/VolatileImageAPI.htm
Using VolatileImage (Page last updated May 2001, Added 2001-07-20, Author Someone@sun). Tips:

http://www.javaworld.com/javaworld/jw-06-2001/jw-0622-filters.html
Servlet Filters (Page last updated June 2001, Added 2001-07-20, Author Jason Hunter). Tips:

http://www.numega.com/library/dmpapers/javamem.shtml
Object creation tuning (Page last updated 2000, Added 2001-07-20, Author Daniel F. Savarese). Tips:

http://www.javaworld.com/javaworld/jw-07-2001/jw-0713-optimism.html
The Optimistic Locking pattern (Page last updated July 2001, Added 2001-07-20, Author Yasmin Akbar-Husain and Eoin Lane). Tips:

http://developer.java.sun.com/developer/technicalArticles/JavaLP/Interposing/
Using java.lang.reflect.Proxy (Page last updated July 2001, Added 2001-07-20, Author Tom Harpin). Tips:

http://www7b.boulder.ibm.com/wsdd/library/techarticles/0106_brown/sessionfacades.html
Rules and Patterns for Session Facades (Page last updated June 2001, Added 2001-07-20, Author Kyle Brown). Tips:

http://www.sys-con.com/xml/article2a.cfm?id=229
Scaling web services (Page last updated June 2001, Added 2001-07-20, Author Simeon Simeonov). Tips:

http://developer.java.sun.com/developer/community/chat/JavaLive/2001/jl0619.html
Sun community discussion on "Optimizing Entity Beans" with Akara Sucharitakul (Page last updated June 2001, Added 2001-07-20, Author Edward Ort). Tips:

http://www.sys-con.com/java/article.cfm?id=1081
Optimizing dynamic web pages (Page last updated July 2001, Added 2001-07-20, Author Helen Thomas). Tips:

http://www.sys-con.com/java/article2a.cfm?id=732
J2ME apps, with a discussion of the needs to balance performance (Page last updated June 2001, Added 2001-07-20, Author Glenn Coates). Tips:

http://www.sys-con.com/java/article.cfm?id=712
J2EE challenges (Page last updated June 2001, Added 2001-07-20, Author Chris Kampmeier). Tips:

http://www.microjava.com/articles/techtalk/recycle
Reusing objects in embedded Java (Page last updated July 2001, Added 2001-07-20, Author Angus Muir and Roman Bialach). Tips:

http://www.microjava.com/chapter2
Chapter 2, "Java: Fat and Slow?", of "Java 2 Micro Edition: Professional Developer's Guide" referenced from http://www.microjava.com/articles/techtalk/giguere(Page last updated May 2001, Added 2001-07-20, Author Eric Giguere). Tips:

http://www.bastie.de/resource/res/mjp.pdf and http://www.bastie.de/java/mjperformance/contents.html
Performance tuning report in German, recently updated. Thanks to Peter Kofler for extracting the tips. (Page last updated June 2001, Added 2001-07-20, Author Sebastian Ritter). Tips:

Jack Shirazi


Last Updated: 2017-10-01
Copyright © 2000-2017 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/newsletter008.shtml
RSS Feed: http://www.JavaPerformanceTuning.com/newsletters.rss
Trouble with this page? Please contact us