https://wiki.openjdk.java.net/display/shenandoah/Main
Basic configuration
Basic configuration and command line options:
-Xlog:gc (since JDK 9) or -verbose:gc (up to JDK 8) would print the individual GC timings.
-Xlog:gc+ergo (since JDK 9) or -XX:+PrintGCDetails (up to JDK 8) or would print the heuristics decisions, which might shed light on outliers, if any.
-Xlog:gc+stats (since JDK 9) or -verbose:gc (up to JDK 8) would print the summary table on Shenandoah internal timings at the end of the run.
It is almost always a good idea to run with logging enabled. This summary table conveys important information about GC performance, and we would almost inevitably ask for one in a performance bug report. Heuristics logs are useful to figure out GC outliers.
Other recommended JVM options are:
-XX:+AlwaysPreTouch: committing heap pages into memory helps to reduce latency hiccups
-Xms and -Xmx: making the heap non-resizeable with -Xms = -Xmx reduces hiccups with heap management. Coupled with AlwaysPreTouch, the -Xms = -Xmx would commit all memory on startup, which avoids hiccups when memory is finally used. -Xms also defines the low boundary for memory uncommit, so with -Xms = -Xmx all memory would stay committed. That said, if you want to configure Shenandoah for lower footprint, then setting lower -Xms is recommended. You need to decide how low to set it to balance the commit/uncommit overhead vs memory footprint. In many cases, setting -Xms arbitrarily low would be fine.
Using large pages greatly improves performance on large heaps. There are two ways to opt-in. -XX:+UseLargePages would enable hugetlbfs (Linux) or Windows (with appropriate privileges) support. -XX:+UseTransparentHugePages would enable it transparently. With transparent huge pages, it is recommended to set /sys/kernel/mm/transparent_hugepage/enabled and /sys/kernel/mm/transparent_hugepage/defrag to «madvise». When running with AlwaysPreTouch, it will also pay the defrag costs upfront at startup.
-XX:+UseNUMA: while Shenandoah does not support NUMA explicitly yet, it is a good idea to enable this to enable NUMA interleaving on multi-socket hosts. Coupled with AlwaysPreTouch, it provides better performance than the default out-of-the-box configuration
-XX:-UseBiasedLocking: there is a tradeoff between uncontended (biased) locking throughput, and the safepoints JVM does to enable and disable them as needed. For latency-oriented workloads, it makes sense to turn biased locking off.
-XX:+DisableExplicitGC: invoking System.gc() from user code forces Shenandoah to perform additional GC cycle; it might be profitable to disable this to protect from the code that abuses System.gc(). It usually does not hurt, as -XX:+ExplicitGCInvokesConcurrent gets enabled by default, which means the concurrent GC cycle would be invoked, not the STW Full GC.
Heuristics