I am using jstat to get the total accumulated time for GC operations, i.e. GCT
So, assume GCT is 2 seconds, and my JVM process started for 60 seconds, am I an running on Quad Core sever, so my % of GC is
2 / 60 * 4 = 0.83%
Is my calculation above correct?
Very long full garbage collections (GC). Some Full GCs take more than 5 minutes. Minor (young) GCs are taking over 30 seconds. Thread dumps show threads in a state "BLOCKED (on object monitor)" in code that isn't even synchronized and shouldn't be blocking for any objects.
Typically, your JVM should: Spend less than 0.5 seconds in each GC cycle. The percentage of time in garbage collection should be less than 3% - This percentage can be calculated by dividing the sum of the garbage collection times over an interval by the interval.
time: Report Time Spent in Garbage Collection.
Global Collection Count Indicates the total number of global garbage collections that occurred during the sample period. Global Mark Phase Avg Collection Interval Indicates the average interval in seconds between global mark phase (GMP) collections.
No, your calculation is not precise, because this way, you don't know the exact time for which the OS allowed your program to run.
Assuming that you want to consider the time for which the application was completely stopped by the GC (pause time), you can use the following JVM options:
-XX:+PrintGCApplicationConcurrentTime
-XX:+PrintGCApplicationStoppedTime
This options will make the JVM print something like this to stdout:
Application time: 3.3319318 seconds
Total time for which application threads were stopped: 0.7876304 seconds
Application time: 2.1039898 seconds
Total time for which application threads were stopped: 0.4100732 seconds
You can then sum up the times for which the application was stopped and divide it by the sum of application time plus the pause time to get the mutator utilization (fraction of time in which the application was not paused by GC).
See also http://prefetch.net/blog/index.php/2008/02/18/measuring-the-time-an-application-was-stopped-due-to-garbage-collection/
no, not really. your calculation assumes 100% utilization of all 4 cores by the java processes during the whole time.
the correct calculation is (time spent in logic) / (time spent in gc)
but getting the 1st piece of information usually requires a profiler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With