ZGC-depth study

ZGC Profile

The research goal is to select the next jdk11 (long-term support) debut zgc.

zgc describes the simple translation of the main Page zgc: ZGC Profile

Further reference hotspot garbage collector team introduced zgc with PPT: https://archive.fosdem.org/2018/schedule/event/zgc/attachments/slides/2211/export/events/attachments/zgc/slides/2211/ZGC_FOSDEM_2018. pdf

 

ZGC keyword

  • region base: distinguished from G1, zgc support dynamic decision region size, region size schema: small (2m ), medium (32m), large (2 * nm)
  • load barrier and color pointer: the reason zgc in most of the steps can be recovered concurrent (a little difference with the store barrier other garbage collector, to be thorough)
  • 10ms : STW only traverse the GC root, so it does not heap becomes large and slow, and this is the reason why the STW can be maintained at less than 10ms
  • 64-bit pointers : Use 64-bit pointer bit is not used for recording the metadata, and therefore do not support the pointer compression does not support 32-bit platforms. Currently, 42 for storing a target address, four process metadata stored gc, 18 undeveloped


ZGC gc strategy and recovery process-related parameters (for details see: ZGC gc strategy and recovery process - source code analysis ):

-XX:ZCollectionInterval

Fixed intervals gc, the default value is 0.

-XX:ZAllocationSpikeTolerance

A memory allocation estimated rate correction factor, the default value is 2. Generally do not need to change

-XX:ZProactive

Whether to enable proactive recovery strategies, the default value is true. General recommendations open

 

Other parameters analysis

This article only ZGC related parameters were analyzed, jdk related parameter is not the scope of this study

1, activation of ZGC: -XX: UseZGC

2, configure the number of concurrent threads: -XX: ConcGCThreads = <number>

Number of concurrent threads, too much will cause the number of concurrent threads take up too much cpu time slice, too little can lead to the recovery speed to keep up with garbage production rate. If the pursuit of low latency, try not to let the system work overload, cpu utilization try to control 70%

3, return unused memory to the OS: -XX: ZUncommit

This refers to the situation set xms and xmx and xmx> xms of, zgc default will return memory to the operating system is not used for the memory system is an important indicator of the level of returns can observe the memory usage better memory unused. But if you want to disable this feature, you can use: -XX: -ZUncommit. But no matter what strategy to use, jvm will not uncommit unsed memery cause heap size is less than xms. This also means that if the configuration xms = xmx, this feature is implicitly disabled

4、启用Large Pages:-XX:+UseLargePages -XX:ZPath 

Large Pages in Linux called Huge Pages, arranged zgc using Huge Pages can achieve better performance (throughput, delay, start time), and substantially no disadvantages, in addition to a little more complicated configuration. Huge Pages size configuration, except to note JVM stack need to use other memory have also included, with the typically used ZPath. Configuration can see: ZGC introduction in the Enbling Large Page

5, 启用 NUMA Support: -XX: UseNUMA

zgc NUMA support enabled by default, meaning that when allocating heap memory, will try to use NUMA-local memory (inter-die access than three times faster). But when a jvm found that use only a subset of the cpu (Limited use), it will automatically disable the feature. This feature generally do not need attention

6. Enable Transparent Huge Page (THP)

Generally do not recommend the use of delay-sensitive System, THP so that a layer of abstraction management Huge Pages automation.

7, Relocate, the region will be greater than if the current fragmentation ZFragmentationLimit, is the recycling region, relocate to the current candidate relocation set.

-XX: ZFragmentationLimit, the default value of 25

8, the print setting ZStat statistics (CPU, memory, etc. log) spacing -XX: ZStatisticsInterval

 

ZGC deficiencies

Currently zgc still marked as experimental, indicating not mature enough, vm parameters constantly adjust. That ZGC experimental performance in some large memory of the scene in a good performance, but also that there are some shortcomings ZGC, are:

  • ZGC only achieve a single generation of memory management, data that is not considered hot and cold data, the C4 has been in business support. It is said Auzl realization of generational memory manager 10 times higher than those without generational memory management efficiency (and did not find the relevant information document), that is to say ZGC there is huge room for improvement;
  • Support C2 is still not perfect;
  • It does not support Graal, HDSB and other functions. 

 

Deprecated

1.Deprecated in jdk12

-XX:ZConcurrentStringTable

-XX:ZConcurrentVMWeakHandles

-XX:ZMarkStacksMax

-XX:ZWeakRoots

-XX:ZOptimizeLoadBarriers

-XX:ZStallOnOutOfMemory

-XX:ZSymbolTableUnloading

2.Deprecated in jdk13

-XX:ZUnmapBadViews

 

other

-XX:ZMarkStackSpaceLimit(jdk12才有的参数):Maximum number of bytes allocated for mark stacks

-XX:ZUncommit(jdk13才有的参数):Uncommit unused memory

-XX:ZUncommitDelay (jdk13才有的参数):Uncommit memory if it has been unused for the specified amount of time (in seconds)

 

Materials and tools

jdk jvm parameter query tool: https://chriswhocodes.com

jdk11 Source: https://download.java.net/openjdk/jdk11/ri/openjdk-11+28_src.zip

ZGC and G1 are the same as region-base garbage collector, G1 Paper:  https://www.researchgate.net/publication/221032945_Garbage-First_garbage_collection

ZGC reference implementation of the algorithm C4, C4 Paper Azul: https://www.azul.com/files/c4_paper_acm1.pdf

ZGC other relevant information: https://archive.fosdem.org/2018/schedule/event/zgc/attachments/slides/2211/export/events/attachments/zgc/slides/2211/ZGC_FOSDEM_2018.pdf

ZGC-related books: "Design and Implementation of ZGC"

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

R big blog: https://www.iteye.com/blog/rednaxelafx-362738 

jvm tuning reference of the southern white blog: http://calvin1978.blogcn.com/articles/jvmoption-7.html

Other references:

What is NUMA architecture: http://cenalulu.github.io/linux/numa/

huge pages:https://www.kernel.org/doc/html/latest/admin-guide/mm/hugetlbpage.html

linux memery commit: http://linuxperf.com/?p=102

Memery Barrier:https://mechanical-sympathy.blogspot.com/2011/07/memory-barriersfences.html

什么是JEP、JSR、JLS:https://stackoverflow.com/questions/51282326/what-is-the-difference-or-relation-between-jls-jsr-and-jep

Guess you like

Origin www.cnblogs.com/JunFengChan/p/11707360.html