Reputation: 642
What's the simplest way to determine Oracle Java 8 JVM garbage collector throughput, preferably using JDK command line tools?
With the jstat command I can obtain total garbage collection time (GCT column). Based on comparing the changes in this value with GC logs, it seems that the GCT value output by jstat is the cumulative GC elapsed time in seconds (since JVM startup). Is this correct?
So, can I calculate GC throughput like this?
1 - GCT / time_since_jvm_start
jstat could be used to obtain both the GC and time since JVM start using the following command:
jstat -gcutil -t <jvm-pid> 1000 1
Upvotes: 2
Views: 2845
Reputation: 13696
You are correct in your question. The GCT
column contains the total time the JVM was stopped to perform garbage collection, both in young GC and full GC.
You could use jstat as you write (jstat -gcutil -t <jvm-pid> 1000 1
) and look at the first column to see the total time the JVM has been running. Let's call this uptime
. Both this timestamp and the GC times are in seconds. If you then want to calculate the percentage of time not spent in GC you would do, exactly as you write:
1 - GCT / uptime
I would argue that calling this throughput is a bit misleading. For example if you use the CMS collector, GC happens in parallel with the application, lowering the application throughput while it does not actually stop the application.
Upvotes: 4