Sun Microsystems Logo
First Previous Next Last Overview
 

LAB-1205: Java Application Performance Analysis

Exercise 10: Use the server compiler (and get compilation information)

Learning goals of this exercise

In this exercise you will learn:

Background for this exercise

Please see Exercise 1 for an overview of running the javaperf GUI launcher.

If you are running this lab on a workstation the Java 5.0 JVM would probably choose the client compiler by default. As of Java 5.0 there are more elaborate heuristics on choosing default compiler and heap settings as described in the Ergonomics in the 5.0 Java Virtual Machine document.

To avoid any guesswork we deliberately set the client compiler in Exercise 9. The client JIT compiler is very quick to startup and is optimal for GUI applications. The server compiler produces somewhat more optimal code (at the expense of longer startup time).  For server type workloads the server compiler will likely provide better performance.

Steps to follow

  1. For this exercise we keep the settings as in Exercise 9, but switch to the server compiler.
    compiler=-server
    heap=-XX:PermSize=12m -XX:MaxPermSize=12m -XX:NewSize=4m -XX:MaxNewSize=4m -Xms16m -Xmx16m
    gc=-XX:+DisableExplicitGC
    other=-XX:+PrintCompilation

  2. Click [Start]. You will see the Java 2D Demo application start....  Immediately click on the "Transforms" tab. Then click into the "Shear" area so it fills the entire window.

  3. Notice the compilation activity is different in the "Graph" pane of Visual GC.

  4. When you see that the application runtime goes just over one minute click [Stop]

  5. Here the overall time in GC is about the same as before.  Did the application perform better?

Summary

When should you use the client compiler vs. the server compiler?  This really depends on your application.  If fast startup is important then the client compiler is certainly what you need.  However, some very intense, long-running GUI applications may benefit from -server.  In the same way some server applications may have better performance with -client.  If footprint is an important criterion for performance then -client will be better as that generated code is often more compact.  Measuring application "output" is going to be a better indication of which compiler is best (rather than the time spent in GC).

Note that in this example we had only about 55 compiles.

The benefit of Ergonomics in Java 5.0 is that the JVM usually chooses the correct compiler setting without you having to do anything!

Next Steps