В OracleJDK / Hotspot 8 и ниже я использовал этот набор флагов:
-XX:+PrintAdaptiveSizePolicy
-XX:+PrintGCApplicationConcurrentTime
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintGCCause
-XX:+PrintGCDateStamps
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintTenuringDistribution
-XX:+UnlockCommercialFeatures
-XX:+UnlockExperimentalVMOptions
-XX:+UseG1GC
Для регистрации событий G1GC.
В старом формате я мог видеть в каждой молодой коллекции, что именно заняло сколько времени.
Пример:
2.130: [G1Ergonomics (CSet Construction) finish choosing CSet, eden: 26 regions, survivors: 0 regions, old: 0 regions, predicted pause time: 3284.94 ms, target pause time: 40.00 ms]
, 0.0409345 secs]
[Parallel Time: 36.4 ms, GC Workers: 8]
[GC Worker Start (ms): Min: 2130.0, Avg: 2130.1, Max: 2130.2, Diff: 0.2]
[Ext Root Scanning (ms): Min: 0.7, Avg: 0.9, Max: 1.9, Diff: 1.2, Sum: 7.5]
[Update RS (ms): Min: 0.0, Avg: 0.9, Max: 1.5, Diff: 1.5, Sum: 7.1]
[Processed Buffers: Min: 0, Avg: 1.1, Max: 2, Diff: 2, Sum: 9]
[Scan RS (ms): Min: 5.9, Avg: 9.5, Max: 13.7, Diff: 7.8, Sum: 76.0]
[Code Root Scanning (ms): Min: 0.0, Avg: 0.7, Max: 1.4, Diff: 1.4, Sum: 5.5]
[Object Copy (ms): Min: 20.3, Avg: 24.0, Max: 27.0, Diff: 6.6, Sum: 191.6]
[Termination (ms): Min: 0.0, Avg: 0.1, Max: 0.3, Diff: 0.3, Sum: 1.1]
[Termination Attempts: Min: 1, Avg: 193.6, Max: 248, Diff: 247, Sum: 1549]
[GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.1]
[GC Worker Total (ms): Min: 36.0, Avg: 36.1, Max: 36.2, Diff: 0.2, Sum: 289.0]
[GC Worker End (ms): Min: 2166.3, Avg: 2166.3, Max: 2166.3, Diff: 0.0]
[Code Root Fixup: 0.3 ms]
[Code Root Purge: 0.0 ms]
[Clear CT: 0.7 ms]
[Other: 3.5 ms]
[Choose CSet: 0.0 ms]
[Ref Proc: 2.2 ms]
[Ref Enq: 0.0 ms]
[Redirty Cards: 0.7 ms]
[Humongous Register: 0.1 ms]
[Humongous Reclaim: 0.0 ms]
[Free CSet: 0.1 ms]
[Eden: 208.0M(11.0G)->0.0B(10.9G) Survivors: 0.0B->32.0M Heap: 212.0M(21.9G)->32.1M(21.9G)]
[Times: user=0.22 sys=0.01, real=0.04 secs]
Однако после того, как я переключился на Oracle Hotspot JDK 9.
Я изменил это на эти параметры согласно документации Oracle:
-Xlog:safepoint,gc*,gc+ergo*=trace,gc+age=trace
Все, что я вижу, это:
[2018-05-03T11:39:16.592-0700][65.378s] GC(8) - age 1: 104795024 bytes, 104795024 total
[2018-05-03T11:39:16.592-0700][65.378s] GC(8) Running G1 Free Collection Set using 8 workers for collection set length 1404
[2018-05-03T11:39:16.593-0700][65.379s] GC(8) MMU target violated: 41.0ms (40.0ms/41.0ms)
[2018-05-03T11:39:16.593-0700][65.379s] GC(8) Updating Refinement Zones: update_rs time: 0.495ms, update_rs buffers: 113, update_rs goal time: 3.590ms
[2018-05-03T11:39:16.593-0700][65.379s] GC(8) Updated Refinement Zones: green: 10, yellow: 30, red: 50
[2018-05-03T11:39:16.593-0700][65.379s] GC(8) Pre Evacuate Collection Set: 0.2ms
[2018-05-03T11:39:16.593-0700][65.379s] GC(8) Evacuate Collection Set: 314.6ms
[2018-05-03T11:39:16.593-0700][65.379s] GC(8) Post Evacuate Collection Set: 6.1ms
[2018-05-03T11:39:16.593-0700][65.379s] GC(8) Other: 0.5ms
[2018-05-03T11:39:16.593-0700][65.379s] GC(8) Eden regions: 1325->0(1389)
[2018-05-03T11:39:16.593-0700][65.379s] GC(8) Survivor regions: 79->15(176)
[2018-05-03T11:39:16.593-0700][65.379s] GC(8) Old regions: 9->81
[2018-05-03T11:39:16.593-0700][65.379s] GC(8) Humongous regions: 9->9
[2018-05-03T11:39:16.593-0700][65.379s] GC(8) Metaspace: 80171K->80171K(1124352K)
[2018-05-03T11:39:16.593-0700][65.379s] GC(8) Pause Young (G1 Evacuation Pause) 11364M->830M(22472M) 321.378ms
[2018-05-03T11:39:16.593-0700][65.379s] GC(8) User=2.43s Sys=0.07s Real=0.32s
Мои источники:
https://blog.gceasy.io/2017/10/17/43-gc-logging-flags-removed-in-java-9/
А также
https://docs.oracle.com/javase/9/tools/java.htm#GUID-BE93ABDC-999C-4CB5-A88B-1994AAAC74D5__CONVERTRUNTIMELOGGINGFLAGSTOXLOG-A504703E
Однако, как я могу узнать, сколько времени на самом деле тратится на каждом из этапов (Object Copy vs Update RS ..)
Спасибо