• Home
    • View
    • Login
    This page
    • Normal
    • Export PDF
    • Page Information

    Loading...
  1. Dashboard
  2. Undefined Space
  3. Shenandoah
  4. Main

Page History

Versions Compared

Old Version 13

changes.mady.by.user Aleksey Shipilev

Saved on Feb 20, 2017

compared with

New Version 14

changes.mady.by.user Aleksey Shipilev

Saved on Feb 20, 2017

  • Previous Change: Difference between versions 12 and 13
  • Next Change: Difference between versions 14 and 15
  • View Page History

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Shenandoah GC

Shenandoah is an ultra-low pause time garbage collector that reduces GC pause times by performing more garbage collection work concurrently with the running Java program. CMS and G1 both perform concurrent marking of live objects. Shenandoah adds concurrent compaction. 

Table of Contents
minLevel2

Build and Run 

Shenandoah is under development. There are several ways to try it:

  1. Build the bleeding edge from the JDK 9 source. This would guarantee you run the latest and greatest version. Adding --enable-debug to configure would produce the "fastdebug" build.

    Code Block
    languagebash
    $ hg clone http://hg.openjdk.java.net/shenandoah/jdk9 shenandoah-jdk9
    $ cd shenandoah-jdk9/
    $ sh ./get_source.sh
    $ sh ./configure
    $ make images
    $ build/linux-x86_64-normal-server-release/images/jdk/bin/java -XX:+UseShenandoahGC -Xlog:gc
    [...][info][gc] Using Shenandoah
    
  2. Build the JDK 8 backport: same as above, but change "jdk9" to "jdk8u" in the paths above. The advantage is that you don't need to figure out JDK 9 compatibility issues for your application first (although it is a good idea to try JDK 9 now anyway). The downside is, that forest may easily be several months behind the JDK 9 version. If you encounter trouble with JDK 8 version, please try JDK 9 version. 

    Code Block
    languagebash
    $ hg clone http://hg.openjdk.java.net/shenandoah/jdk8u shenandoah-jdk8u
    $ cd shenandoah-jdk8u/
    $ sh ./get_source.sh
    $ sh ./configure
    $ make images
    $ build/linux-x86_64-normal-server-release/j2sdk-image/bin/java -XX:+UseShenandoahGC -version
    openjdk version "1.8.0-internal"
    OpenJDK Runtime Environment (build 1.8.0-internal-shade_2016_12_19_15_52-b00)
    OpenJDK 64-Bit Server VM (build 25.71-b00, mixed mode)
  3. Pick up the binary build from AdoptOpenJDK (jdk8, jdk9 – look at the publish dates, the builds might be outdated), or others (e.g. builds.shipilev.net).
     

  4. In some Linux distros, Shenandoah is available within the IcedTea binaries. The caveat is that those may lag behind the current development version even more.

    1. Fedora 24/25:

      Code Block
      languagebash
      $ cat /etc/redhat-release 
      Fedora release 25 (Twenty Five)
      $ java -XX:+UseShenandoahGC -version
      OpenJDK 64-Bit Server VM warning: Compressed Oops not supported with ShenandoahGC
      openjdk version "1.8.0_111"
      OpenJDK Runtime Environment (build 1.8.0_111-b16)
      OpenJDK 64-Bit Server VM (build 25.111-b16, mixed mode)
    2. Gentoo ebuilds for IcedTea have Shenandoah USE flag.

Functional Diagnostics

This section describes the ways one can diagnose and/or debug Shenandoah. 

Hints for Early Adopters/Developers

Basic configuration and command line options:

  • In many cases, running with fastdebug build will produce the meaningful assert messages, pointing at the earliest moment when GC detected the functional anomaly, and Shenandoah asserts a lot. These builds can be produced by adding --enable-debug to configure, and re-building.
  • In many cases, running with -XX:ShenandoahGCHeuristics=aggressive is an efficient way to shake out GC bugs. This heuristics runs back-to-back GCs, and evacuates all non-empty regions. Since Shenandoah does most GC heavy-lifting concurrently, this does not block application from executing, although GC would consume much more cycles in this mode and slow the application down.
  • It is possible to disable concurrent GCs with -XX:ShenandoahGCHeuristics=passive, which will do the stop-the-world mark-compact GCs only, and avoid doing most of concurrent work.
  • Shenandoah supports several options that add even more verifications: -XX:+ShenandoahStoreCheck lets C2 compile machine code that checks that writes happen in tospace only. -XX:+ShenandoahVerify runs verification passes across the heap during collection. -XX:+ShenandoahVerifyOptoBarriers verifies barriers in C2's ideal graph. -XX:VerifyStrictOopOperations performs additional checks to verify that oop comparisons are done correctly (fastdebug only).
  • If you suspect a JIT bug (and there are lots of Shenandoah-specific optimizations), it is a very good idea to try bisect which compiler failed by trying several VM modes: -Xint (interpreter only), -XX:TieredStopAtLevel=1 (C1 only), -XX:-TieredCompilation (interpreter and C2 only), default (interpreter, tiered C1, tiered C2).

Approaches for debugging:

  1. Put logging statements in the code around the failing assert to understand the issue better. With enough logging, you can retrace everything that happened in the collector.
  2. Attach a native debugger, for example, gdb, by asking VM to do the external action on failure with -XX:OnError="gdb - %p" (%p would get substituted with process PID)
  3. Create a simple reproducer and hand it over to Shenandoah developers. :)

Bug reports are welcome at the mailing list.

Performance Diagnostics

This section describes the approaches to test and diagnose performance behaviors with Shenandoah.

Basic configuration and command line options:

  • Shenandoah performance, like the performance of almost all other GCs, depends on heap size. We expect it to perform better in cases when there is enough heap space to accommodate allocations while concurrent phases are running. The time for concurrent phases correlates with the live data set size (LDS) -- the space taken by live data. Therefore, the reasonable heap size is dependent on LDS in the workload: larger LDS-es require proportionally larger heap sizes. For some workloads with minuscule live data sets, 1...2 GB heaps performs well. We routinely test on 4...128 GB heaps on various workloads with up to 80% LDS size. Don't be shy to try different heap sizes to see what fits your workload.
     
  • -Xlog:gc=info would  would print the individual GC timings. This is not specific to Shenandoah, most recent GCs with JDK 9 Unified Logging would work like that. 
  • -Xlog:gc+stats would  would print the summary table on Shenandoah internal timings at the end of the run. This summary table conveys important information about GC performance, and we would almost inevitably ask for one in a performance bug report. It is a good idea to always run with it enabled. 
  • If you suspect a GC bug, it is a very good idea to run with "fastdebug" builds. These can be produced by adding --enable-debug to configure, and building. Shenandoah asserts a lot of things, and it usually reveals a lot about the issue.
     
  • If you suspect a JIT bug (and there are lots of Shenandoah-specific optimizations), it is a very good idea to try bisect which compiler failed by trying several VM modes: -Xint (interpreter only), -XX:TieredStopAtLevel=1 (C1 only), -XX:-TieredCompilation (interpreter and C2 only), default (interpreter, tiered C1, tiered C2).
     
  • If you suspect a bug in concurrent phases, read/write barriers, etc., try running with -XX:ShenandoahGCHeuristics=passive, which will do the stop-the-world mark-compact GCs only, and avoid doing most of concurrent work.
     
  • GC bugs can be shaken out more quickly with -XX:ShenandoahGCHeuristics=aggressive, which runs back-to-back GCs. Since Shenandoah does most GC heavy-lifting concurrently, this does not block application from executing, although GC would consume much more cycles in this mode and slow the application down.
     
  • Shenandoah supports several options that add even more verifications: -XX:+ShenandoahStoreCheck lets C2 compile machine code that checks that writes happen in tospace only. -XX:+ShenandoahVerify runs verification passes across the heap during collection. -XX:+ShenandoahVerifyOptoBarriers verifies barriers in C2's ideal graph. -XX:VerifyStrictOopOperations performs additional checks to verify that oop comparisons are done correctly (fastdebug only).
Bug reports are welcome at the mailing list

Approaches to performance analysis:

  1. Some odd performance behaviors – like the allocation failure GCs, or long final marks – can be explained by heuristics issues. If you have a long-running workload, running under ShenandoahVisualizer would let you understand the high-level GC behavior. Sometimes the odd behavior is clearly visible there.
  2. Some performance difference can be explained by larger allocation pressure under Shenandoah, since it includes the forwarding pointer with each object. Look at the allocation rates to see if that might be a problem, and do experiments that could confirm this (for example, beefing up objects should diminish the performance difference against another collector). There are some cases when larger footprint means dropping out of CPU cache, look for L1/L2/LLC miss differences.
  3. Many performance differences can be explained by GC barriers. Fortunately, when running with -XX:ShenandoahGCHeuristics=passive, barriers are not required for correctness, and so we can selectively disable them to see if that improves performance on a particular workload. The options are:
    1. -XX:-ShenandoahReadBarrier: disables read barriers
    2. -XX:-ShenandoahWriteBarrier: disables write barriers (pre-store SATB barriers, pre-store "to-space write" barriers, and any other write-related barriers)
    3. -XX:-ShenandoahAcmpBarrier: disables acmp ("==") barriers
    4. -XX:-ShenandoahCASBarrier: disables compareAnd{Set,Exchange} barriers
    5. -XX:-ShenandoahCloneBarrier: disables object/array clone barriers
  4. Profiling the native code in GC is easy with Linux perf:
    1. Build OpenJDK with --with-native-debug-symbols=internal
    2. Run the workload with perf record java ... or perf record -g java ...
    3. Open the report with perf report
  5. Profiling the barriers code requires PrintAssembly-enabled build. We recommend to use JMH -prof perfasm to create the isolated scenarios and looking at the generated code under Shenandoah.

Resources

  • Shenandoah Project
  • Repositories
  • Mailing list: shenandoah-dev
  • Members

Recently Updated

Navigate space

Page Tree Search

Page Tree

 

Overview
Content Tools
ThemeBuilder

Terms of Use
• License: GPLv2
• Privacy • Trademarks • Contact Us

Powered by a free Atlassian Confluence Open Source Project License granted to https://www.atlassian.com/software/views/opensource-community-additional-license-offer. Evaluate Confluence today.

  • Kolekti ThemeBuilder Powered by Atlassian Confluence 8.5.21
  • Kolekti ThemeBuilder printed.by.atlassian.confluence
  • Report a bug
  • Atlassian News
Atlassian
Kolekti ThemeBuilder EngineAtlassian Confluence
{"serverDuration": 292, "requestCorrelationId": "4e82ddd40431911b"}