Generally speaking the CPU utilization of CMS garbage collector (or any other concurrent garbage collector) is higher than the throughput garbage collector and it's mentioned in the book Java performance The definitive guide on page 108:
When using the CMS or G1 collector, an application will typically
experience fewer (and much shorter) pauses. The trade-off is that the
application will use more CPU overall.
And on page 109:
The benefit of avoiding long pause times with a concurrent collector
comes at the expense of extra CPU usage.
But there is an example in the book on page 115 in which CMS collector has lower CPU utilization(both average and pick):
The throughput collector will (by default) consume 100% of the CPU
available on the machine while it runs, so a more accurate
representation of the CPU usage during this test is shown in Figure
5-2. Most of the time, only the application thread is running,
consuming 25% of the total CPU. When GC kicks in, 100% of the CPU is
consumed. Hence, the actual CPU usage resembles the sawtooth pattern
in the graph, even though the average during the test is reported as
the value of the straight dashed line.
The effect is different in a concurrent collector, when there are
background thread(s) running concurrently with the application
threads. In that case, a graph of the CPU might look like Figure 5-3.
The application thread starts by using 25% of the total CPU.
Eventually it has created enough garbage for the CMS background thread
to kick in; that thread also consumes an entire CPU, bringing the
total up to 50%. When the CMS thread finishes, CPU usage drops to 25%,
and so on. Note that there are no 100% peak-CPU periods, which is a
little bit of a simplification: there will be very short spikes to
100% CPU usage during the CMS young generation collections, but those
are short enough that we can ignore them for this discussion.
Why in this case CMS garbage collector could have lower CPU usage than Throughput garbage collector?
Copyright License:
Author:「Tashkhisi」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/64856149/why-cpu-utilization-of-cms-garbage-collector-is-lower-than-throughput-garbage-co