Tuning ZGC

Let's look at a couple of options to fine-tune ZGC (this chapter covers just a few basic ones). Let's start with the most basic option of setting the max heap size. We can do this by using the following JVM runtime option:

-Xmx<size>

To get the optimal performance, you must set a heap size that can not only store the live set of your application but also has enough space to service the allocations.

ZGC is a concurrent garbage collector. By setting the amount of CPU time that should be assigned to ZGC threads, you can control how often the GC kicks in. You can do so by using the following option:

-XX:ConcGCThreads=<number> 

A higher value for the ConcGCThreads option will leave less amount of CPU time for your application. On the other hand, a lower value may result in your application struggling for memory; your application might generate more garbage than what is collected by ZGC. ZGC can also use default values for ConcGCThreads. To fine-tune your application on this parameter, you might prefer to execute against test values.

For advanced ZGC tuning, you can also enable large pages for enhanced performance of your application. You can do this by using the following option:

-XX:+UseLargePages
The preceding command needs root privileges. Please refer to https://wiki.openjdk.java.net/display/zgc for detailed steps.

Instead of enabling large pages, you can also enable transparent huge pages by using the following option:

-XX:+UseTransparentHugePage

The preceding option also includes additional settings and configurations, which can be accessed by using ZGC's official wiki page, hosted at https://wiki.openjdk.java.net/display/zgc.

ZGC is a NUMA-aware GC. Applications executing on the NUMA machine can result in a noticeable performance gain. By default, NUMA support is enabled for ZGC. However, if the JVM realizes that it is bound to a subset in the JVM, this feature can be disabled. To override a JVM's decision, you can use the following option:

-XX:+UseNUMA
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.36.38