0

The "Total garbage collection time" can be determined by observing the GCT column printed by the command:

jstat -gc <pid>

as described by the documentation here: https://docs.oracle.com/en/java/javase/12/tools/jstat.html

It appears to be an amount of time spent doing GC since the Java process started, measured in seconds.

Is that per core? So, if a quad-core CPU was fully utilized by a single JVM instance for 100 seconds, and was garbage collecting 10% of the time, would GCT report 10 or 40? If I have hyperthreading enabled (i.e. 8 OS cores), then how should I reason about the GCT figure?

I'm using the OpenJDK12 HotSpot JVM.

Andrew Parks
  • 6,358
  • 2
  • 12
  • 27

1 Answers1

2

GCT metric is collector specific. Each GC algorithm may define its own meaning for GCT.

Usually it is the total wall clock time spent in the stop-the-world GC pauses. In particular, for G1, the default collector in OpenJDK 12, GCT is the sum of Full GC pauses + stop-the-world phases of concurrent GC cycles.

However, for Shenandoah GC GCT also includes the concurrent GC time. In either case, GCT is measured with an absolute (wall clock) timer, irrespective of the number of threads or CPU cores.

apangin
  • 92,924
  • 10
  • 193
  • 247
  • Great answer, thank you! Just to clarify, for G1 does that mean that the JVM could be spending 10 seconds out of 100 on stop-the-world/full pauses, and another 85 seconds out of the 100 on non-stop-the-world GC work, and there would be no way to know that the Java process was only managing to use the remaining 5 seconds out of the 100 to run its code? – Andrew Parks Aug 02 '19 at 04:05
  • 1
    @AndrewParks This is an unlikely situation, since the number of concurrent GC threads is limited to a portion of the available cores. The background garbage collection does not prevent application threads from running. – apangin Aug 02 '19 at 11:42
  • 1
    If you want to measure the actual CPU consumption of GC threads vs. Application threads, I suggest [async-profiler](https://github.com/jvm-profiling-tools/async-profiler). – apangin Aug 02 '19 at 11:42