Java SE 6 release 21, the Java Hotspot VM 17.0 and G1

Markus Eisele
4
Oracle released the Java SE 6 (1.6.0_21) build a few days ago. Unexpected this presents a bunch of new features and updates. Here are the major ones in short and a more detailed look at the also included Java Hotspot VM 17.0.

Supported Systems
Beside additional framework support for Oracle Enterprise Linux (4.8 -5.5), Red Hat Enterprise Linux (5.4, 5.5) and the Oracle VM 2.2.0.0.0 this one also supports the 4.0 branch of Google's Chrome.
Look at thecomplete list of all supported system configurations for more details.

Customized Loading Progress Indicators
You can now enhance the loading experience of an application by providing a customized loading progress indicator/progress bar. You can replace the default loading progress indicator with a custom implementation that provides regular feedback about how the RIA is loading. To do this, you have to create a class that implements the DownloadServiceListener interface. Create and update the progress indicator in the following methods based on the overallPercent argument. These methods are invoked regularly by the Java Plug-in software to communicate progress of the applet's download. Java Plug-in software will always send a message when download and validation of resources is 100% complete.

public void progress(URL url, String version, long readSoFar,
long total, int overallPercent) { ... }

public void upgradingArchive(java.net.URL url,
java.lang.String version,
int patchPercent,
int overallPercent) { ... }

public void validating(java.net.URL url,
java.lang.String version,
long entry,
long total,
int overallPercent) { ...}

For mor details look at the new Customizing the Loading Experience tutorial.

Java VisualVM Updates
Now Java VisualVM based on VisualVM 1.2.2 is included. It introduces all related features. Look at the release notes for a list of bugfixes and new features.

268 bugfixes
Java SE 6 Update 21 does not contain any additional fixes for security vulnerabilities compared toUpdate 20. So there is basically no need to update. Beside this, there are 268 issues fixed with the new update. Most of them related to "hotspot" category the "runtime system" and the garbage collector. For details please refer to the complete list of bugfixes.

Java Hotspot VM 17.0
The new JVM includes version 17.0 of the Java HotSpot Virtual Machine. This has overall improvements to quality and features such as compressed object pointers, escape analysis-based optimization, code cache management. The most interesting part is the successor of the Concurrent Mark-Sweep garbage, the Garbage First (G1) garbage collector (GC). The G1 is a new GC that is being introduced in the Java HotSpot VM in JDK 7. An first experimental version of G1 has already been released in Java SE 6 Update 14. VM 17.0 now again contains an improved version.

G1 is a "server-style" GC and has the following attributes.
Parallelism and Concurrency. G1 takes advantage of the parallelism that exists in hardware today. It uses all available CPUs (cores, hardware threads, etc.) to speed up its "stop-the-world" GC pauses. It also works concurrently with running Java threads.

Generational. Like the other HotSpot GC's, G1 is generational, meaning it treats newly-allocated (aka young) objects and objects that have lived for some time (aka old) differently. But there is no physical separation between the young and old generations. Instead, there is a single contiguous heap which is split into same-sized regions. The young generation is a set of potentially non-contiguous regions, and the same is true for the old generation. This allows G1 to flexibly move resources as needed from the old to the young generation, and vice versa.

Compaction. Unlike CMS, G1 performs heap compaction over time. Compaction eliminates potential fragmentation problems to ensure consistent long-running operation.

Predictability. G1 is expected to be more predictable than CMS. This is largely due to the elimination of fragmentation issues that can negatively affect stop-the-world pause times in CMS. Additionally, G1 has a pause prediction model that, in many situations, allows it to often meet (or rarely exceed) a pause time target.

G1 is still considered experimental and is available in Early Access only. It can be enabled with the following two parameters:

-XX:+UnlockExperimentalVMOptions -XX:+UseG1GC

To set a GC pause time goal:

-XX:MaxGCPauseMillis =50 (for a pause time target of 50ms)

With G1, a time interval can be specified during which a GC pause should last no longer than the time given above:

-XX:GCPauseIntervalMillis =200 (for a pause interval target of 200ms)

The above two options represent goals. They are not promises or guarantees. They might work well in some situations but not in others.

Alternatively, the size of the young generation can be specified:

-XX:+G1YoungGenSize=512m (for a 512 megabyte young generation)

There are also comparable survivor spaces, which are, a set of (potentially non-contiguous) regions. Their size can be specified with the usual parameters (e.g., -XX:SurvivorRatio=6).

To run G1 at its full potential use these two parameters. They are currently disabled by default because they may uncover a rare race condition:

-XX:+G1ParallelRSetUpdatingEnabled -XX:+G1ParallelRSetScanningEnabled

My tests with the latest 1.6.0_21 showed, that both parameters are not working. If you are willing to test them, switch back to 1.6.0_20!

One more thing to note is that G1 is very verbose compared to other HotSpot GCs when -XX:+PrintGCDetails is set. This is because it prints per-GC-thread timings and other information very helpful in profiling and trouble-shooting. If you want a more concise GC log, please switch to using -verbosegc.
If you try this with WebLogic Server 11g you get a first impression what this means:
<08.07.2010 18:45 Uhr MESZ> <Info> <WebLogicServer>
<BEA-000377> <Starting WebLogic Server with 
Java HotSpot(TM) Server VM Version 17.0-b16 from 
Sun Microsystems Inc.>
[GC pause (young), 0.05034187 secs]
   [Parallel Time:  47.8 ms]
      [Update RS (Start) (ms):  83057.1  83058.3]
      [Update RS (ms):  1.0  0.0
       Avg:   0.5, Min:   0.0, Max:   1.0]
         [Processed Buffers : 15 0
          Sum: 15, Avg: 7, Min: 0, Max: 15]
      [Ext Root Scanning (ms):  35.6  33.4
       Avg:  34.5, Min:  33.4, Max:  35.6]
      [Mark Stack Scanning (ms):  0.0  0.0
       Avg:   0.0, Min:   0.0, Max:   0.0]
      [Scan-Only Scanning (ms):  0.0  0.0
       Avg:   0.0, Min:   0.0, Max:   0.0]
         [Scan-Only Regions : 0 0
          Sum: 0, Avg: 0, Min: 0, Max: 0]
      [Scan RS (ms):  0.3  0.0
       Avg:   0.2, Min:   0.0, Max:   0.3]
      [Object Copy (ms):  10.8  9.9
       Avg:  10.3, Min:   9.9, Max:  10.8]
      [Termination (ms):  0.0  0.0
       Avg:   0.0, Min:   0.0, Max:   0.0]
      [Other:   2.3 ms]
   [Clear CT:   0.1 ms]
   [Other:   2.4 ms]
   [ 200M->26M(256M)]
 [Times: user=0.08 sys=0.03, real=0.06 secs]

[...]

[Full GC (System.gc()) 65M->27M(256M), 0.4923866 secs]
 [Times: user=0.53 sys=0.00, real=0.50 secs]
See the G1 technology page for more information.
There has been a JavaOne session about the G1 in 2008. Find some slides and more on this page.

Post a Comment

4Comments

  1. Is it still possible to download JRE 6u21 b06 with the "Oracle" string somewhere? I would like to test my own software, too.

    ReplyDelete
  2. Hi Matthias,
    Don't Know about it. I guess you have to check against jdk7. This will probably Not Happen again with 1.6.x

    ReplyDelete
  3. Some of those GC options appear missing from 1.6.0_21-b06 (linux 64bit).

    -XX:+G1YoungGenSize=512m
    -XX:+G1ParallelRSetUpdatingEnabled -XX:+G1ParallelRSetScanningEnabled

    Each gives an error like this:

    Unrecognized VM option '+G1YoungGenSize=512m'
    Could not create the Java virtual machine.

    ReplyDelete
  4. Hi Sean,

    yes, seen this too. Don't have a clue. But remember it's still flagged as experimental. Should be fully working with latest JDK 7 ...

    ReplyDelete
Post a Comment