Java Reference
In-Depth Information
Incremental CMS
This chapter has continually stressed the fact that extra CPU is needed to run CMS effect-
ively. What if you have only a single-CPU machine, but still need a low-pause collector? Or
have multiple, but very busy, CPUs?
INCREMENTAL CMS IS DEPRECATED IN JAVA 8
Incremental CMS (iCMS) is deprecated in Java 8—it still exists, but it may not be part of Java 9.
The main advantage to incremental CMS is that the background thread pauses periodically to al-
low application threads to run, making it usable on machines with limited CPUs. As multiple
CPUs become the norm for all systems (even my phone has a quad-core chip), the rational for
iCMS becomes less important.
On systems with limited CPU, consider the G1 collector instead—particularly since the back-
ground threads of G1 also will periodically pause during a background cycle, limiting the compet-
ition for the CPU.
In those cases, CMS can be set so that it operates incrementally, which means that when the
background thread runs (and there should never be more than one such thread), it doesn't
sweep through the entire heap at once. Having that background thread pause periodically will
help overall throughput by making more CPU available to the application thread(s). When it
does run, though, the application threads and the CMS thread will still compete for CPU
cycles.
Incremental CMS is enabled by specifying the -XX:+CMSIncrementalMode flag. The rate at
which the background thread yields to the application threads is controlled by changing the
values of the -XX:CMSIncrementalSafetyFactor= N , -XX:CMSIncrement-
alDutyCycleMin= N , and -XX:-CMSIncrementalPacing flags.
Incremental CMS operates on the principle of a duty cycle, which governs how long the
CMS background thread will scan the heap before yielding time to the application threads.
At the operating system level, the background thread is already competing with (and will be
time-sliced with) the application threads. These flags instead control how long the back-
ground thread will run before voluntarily stopping for a while to let the application threads
run.
The duty cycle is calculated in terms of the length of time between collections of the young
generation; by default, incremental CMS will be allowed to run for 20% of that time (at least
Search WWH ::




Custom Search