I know we can get the GC duration from the GarbageCollectionNotificationInfo object, but the duration there seems to be the entire duration (e.g., I found 5+ seconds once) which could be much larger than the actual stop the world pause (typically less than 1 seconds from my experience), is there anyway we can get the actual stop the world pause duration? Either somehow calculated from the available sources (I do not think GarbageCollectionNotificationInfo provide us with those details? but I could be wrong) or any other ways? I know jstat tool prints the FGCT column which seems to be reflecting exactly the stop the world pause time, how do they do that then? Thanks in advance!
1 Answer
To get all STW pauses in the VM log output you need to pass the following two options. This includes non-GC safepoints.
-XX:+PrintSafepointStatistics –XX:PrintSafepointStatisticsCount=1
Alternatively there's -XX:+PrintGCApplicationStoppedTime
Keep in mind that non-safepoint things can induce pauses too (e.g. the kernel's thread scheduler). There's jHiccup to measure those.
-
how about programmatic access to that pause time? with GCNotificationInfos you can monitor from within the application and do some alerting/reporting if needed. Is there a way to acheive programmatic access? (without nasty hacks like parsing stdin)– vachCommented Apr 11, 2018 at 2:23
-
@vach not that I am aware of. just monitor the time an application is responsive instead. in the end a safepoint is just yet another incomplete approximation for things most people are actually concerned about. that's what jhiccup does anyway.– the8472Commented Apr 12, 2018 at 19:12
GcInfo
object held by the bean say? What you are looking for is data related to "full" collections, as partial collections will not stop the world, and full collections will stop the world for pretty much that whole collection duration.