sigmainfy
sigmainfy

Reputation: 41

How to measure Java GC Stop The World time?

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!

Upvotes: 3

Views: 2813

Answers (1)

the8472
the8472

Reputation: 43052

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.

Upvotes: 2

Related Questions