简体   繁体   中英

How to determine JVM GC throughput?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM