X

Jon Masamitsu's Weblog

  • Java
    September 26, 2005

It's Not Magic

Guest Author

In our J2SE (tm) 1.5.0 release we added a new way of tuning the Java(tm) heap
which we call "garbage collector (GC) ergonomics". This was added
only to the parallel GC collector. You may also have seen it referred
to as "Smart Tuning" or "Simplified Tuning". GC ergonomics allows a
user to tune the Java heap by specifying a desired behavior for
the application. These behaviors are a maximum pause time goal and a
throughput goal.

So what is GC ergonomics? Prior J2SE 1.5.0 if you wanted to
tune the Java Virtual Machine (JVM)(tm) for an application you typically
did it by trial-and-error. You would run the JVM on
your application without changing any parameters and see how it ran.
If the throughput of the application was not as high as you wanted,
the usual solution was to increase the heap size.
With a larger heap collections happen less often so the cost of
garbage collection decreases as a percentage of the total execution
time. But as you increase the size of the heap, often the
length of the garbage collections increase. Since the
garbage collector pauses all application threads to do a collection,
the application would see longer and longer pauses as you chose
larger and larger heaps. If the pauses became too
long for your application, then you would have to reduce the size
of the heap. You usually have to choose a compromise between pause
times and throughput.

With GC ergonomics in J2SE 1.5.0 you choose a pause time goal and a
throughput goal and let the JVM increase or decrease the size of
the heap to try to meet those goals. On big machines a larger
maximum heap size is chosen as a default. GC ergonomics
only grows the heap enough to meet your goals so the maximum
heap size is not necessarily used. Sometimes you might have to
increase the maximum size of the heap if the default maximum size
is too small.

So how does this work? Actually GC ergonomics does pretty much
what you would do to tune the heap. As I say in the title, it's not
magic. But it does have the benefit of being able to tune dynamically
during the execution of the application. GC ergonomics


  • Measures the performance (both throughput and pause times)
    of you application.


  • Compares the performance against the goals.


  • Decreases the heap size to shorten pause times, OR


  • Increases the heap size to get fewer collections.
  • If both the pause time goal and the throughput goal are being met,
    GC ergonomics will decrease the size of the heap to try and minimize
    the application's footprint.

    GC ergonomics tries to meet your goals but there are no guarantees that
    it can. For example, a maximum pause time of zero would be nice, but
    it's not going to happen. Can you tune the heap better that GC
    ergonomics? Probably yes. Is it worth your time to do it? And
    to keep it tuned as your circumstances change? You'll have to tell
    us.

    For more information on GC ergonomics, please see "Ergonomics in the
    5.0 Java Virtual Machine" under

    http://java.sun.com/docs/hotspot

    Be the first to comment

    Comments ( 0 )
    Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.