Why CPU utilization of CMS garbage collector is lower than Throughput garbage collector in this case

2020-11-16T18:15:42

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.

enter image description here

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.

enter image description here

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

About “Why CPU utilization of CMS garbage collector is lower than Throughput garbage collector in this case” questions

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 perfo...
In the book Java Performance The Definitive guide There is a comparison between CPU utilization of throughput garbage Collector and CMS garbage collector as bellow: The throughput collector will (by
I know the CMS garbage collector uses the mark sweep algorithm,I am curious about how it marks the object. CMS initial mark: why does it mark the reachable objects rather than mark unreachable obj...
Does anyone know of any performance benchmarks of Java's new Garbage First (G1) Garbage Collector (as compared to the "old" GCs)? In terms of GC pause times, Sun states that G1 is sometimes bette...
Why CPU registers act like roots for Garbage Collector? When a mutator pauses, so the garbage collector can scan the roots, the variables contents are flushed to memory (using a memory fence) so the
In my application some parts needs to be executed for given time (in minutes typically). Since the application uses a lot of memory I found that in some cases given time can be reduced by running g...
What should I measure while choosing the garbage collector? In my case, I am trying to compare the performance of throughput collector over G1GC, not quite sure what should I look for before makin...
I am working on a little side project, a game of sorts that I built with D3, and I am currently trying optimize performance. Over time it really becomes a problem. Looking at the dev tools, it seem...
I am running an application that creates and forgets large amounts of objects, the amount of long existing objects does grow slowly, but this is very little compared to short lived objects. This is a
Is there a way I can find GC type (parallel or CMS or G1 ) from jnconsole or jvisualvm? In my case, I see below related info: Garbage Collector : Name='PS MarkSweep'.... Garbage Collector : Name=...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.