3

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!

3
  • 1
    What does the 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.
    – user1531971
    Commented Oct 23, 2015 at 0:34
  • GcInfo only has start time, end time since JVM starts and the duration, and the memory usage of different memory pools (e.g., Eden Space), what I actually want to achieve is to get the Stop The World pause time by monitoring the JVM directly (like using a running service), not monitoring say the JVM log output, it would be more desirable if we can directly get or calculated somehow from the data exposed by JVM (e.g., the GarbageCollectionNotificationInfo ),
    – sigmainfy
    Commented Oct 23, 2015 at 4:12
  • Oracle docs say that GcInfo.getDuration() "Returns the elapsed time of this GC in milliseconds." If this GC is a full collection, it has stopped the world for pretty much this entire time. One hopes the other properties on the parent object let you query what sort of GC this is.
    – user1531971
    Commented Oct 23, 2015 at 4:17

1 Answer 1

2

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.

2
  • 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)
    – vach
    Commented 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.
    – the8472
    Commented Apr 12, 2018 at 19:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.