如何测量Java GC停止世界时间? [英] How to measure Java GC Stop The World time?

查看:137
本文介绍了如何测量Java GC停止世界时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我们可以从GarbageCollectionNotificationInfo对象获取GC持续时间,但持续时间似乎是整个持续时间(例如,我发现了5秒以上一次),这可能远远大于实际停止世界暂停(通常距离我的经验不足1秒),反正我们可以得到实际停止世界暂停持续时间吗?无论是从可用的来源计算(我不认为GarbageCollectionNotificationInfo提供给我们这些细节?但我可能是错的)或任何其他方式?我知道jstat工具打印FGCT列,似乎正在反映停止世界暂停时间,他们怎么做呢?提前致谢!

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!

推荐答案

要在VM日志输出中获得所有STW暂停,您需要传递以下两个选项。这包括非GC安全点。

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

另外还有 -XX:+ PrintGCApplicationStoppedTime

请记住,非安全点的东西也会导致暂停(例如,内核的线程调度程序)。有 jHiccup 来衡量这些。

Keep in mind that non-safepoint things can induce pauses too (e.g. the kernel's thread scheduler). There's jHiccup to measure those.

这篇关于如何测量Java GC停止世界时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆