Trying to understand ZGC

Per Liden per.liden at oracle.com
Tue Nov 13 19:21:26 UTC 2018


Hi,

On 2018-11-13 05:53, stefan.reich.maker.of.eye at googlemail.com wrote:
> Hello there, thank you for your lovely garbage collector. I'm currently trying it for desktop use on Linux with JDK 11. (You can try my Java guest OS at www.BotCompany.de.)
> 
> Some things are unclear to me.
> 
> -The process's resident size seems quite large. I specify -Xmx768 and get a resident size of up to 2.5 GB. The machine does not slow down though which is really weird as it only has 3.5 GB in total. Maybe the RSS value is misleading?

The RSS accounting on Linux isn't always telling the complete truth and 
it can even vary depending on if you're using small or large pages. ZGC 
does heap multi-mapping, which means it will map the same heap memory in 
three different locations in the virtual address space. When using small 
pages, Linux isn't clever enough to detect that it's the same memory 
being mapped multiple times, and so it accounts for each mapping as if 
it was new/different, inflating the RSS by 3x. This typically doesn't 
happen when using large pages (-XX:+UseLargePages).

> 
> When turning on GC notifications, I see (sometimes):
> 
>    GC cause:  Allocation Rate (360 ms)
>    Collector: ZGC
>    Changes:   ZHeap: -16383 K, CodeHeap 'profiled nmethods': 85 K, Metaspace: 1 K
> 
> and more often:
> 
>   GC cause:  Proactive (147 ms)
>    Collector: ZGC
>    Changes:   ZHeap: -180223 K, CodeHeap 'profiled nmethods': 1 K, CodeHeap 'non-profiled nmethods': 1 K, Metaspace: 1 K, CodeHeap 'non-nmethods': 12 K
> 
> Does this mean stop-the-world GC pauses are occurring, or is my application not paused?

This is all normal. Each ZGC cycle has three short pauses (each of them 
should be below 10ms). If you enable detailed GC logging with 
-Xlog:gc*:gc.log you'll see more details on exactly how long the pauses 
are, and a bunch of other data points.

For more information on ZGC, how to tune, how to interpret logs, 
internals, etc., I'd recommend having a look at some of the slides 
and/or videos available here:

https://wiki.openjdk.java.net/display/zgc/Main

> 
> I have already upped GC concurrency to 4.
> 
> Generally, everything seems completely fluent, I'm noticing no actual problems apart from the weird stats as outlined above.
> 
> Full command line for good measure:
> 
> /home/stefan/dev/jdk-11.0.1/bin/java --illegal-access=permit -Xmx768m -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -XX:ConcGCThreads=4 -XX:MaxHeapFreeRatio=20 -XX:MinHeapFreeRatio=10 -XX:+UseStringDeduplication --add-opens java.base/jdk.internal.loader=ALL-UNNAMED -jar /home/stefan/.javax/x30.jar 1016478

Note that the following three options have no effect when using ZGC:

-XX:MaxHeapFreeRatio=20
-XX:MinHeapFreeRatio=10
-XX:+UseStringDeduplication

cheers,
Per

> 
> Many greetings,
> Stefan
> 


More information about the zgc-dev mailing list