JVM在GC中花费时间时线程转储是什么样的 [英] What does thread dump looks like when JVM spent time in GC

查看:243
本文介绍了JVM在GC中花费时间时线程转储是什么样的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

分析Java应用程序时,我注意到一个有趣的事实。当JVM处于死亡线程转储的GC螺旋状时,看起来像:

 1304802943 @ qtp-393978767-9985prio = 10 tid = 0x00007f3ed02dd000 nid = 0x74e7在Object.wait()[0x000000004febb000] 
java.lang.Thread.State:TIMED_WAITING(在对象监视器上)$ b $在java.lang.Object.wait(本地方法)
at org.mortbay.thread.QueuedThreadPool $ PoolThread.run(QueuedThreadPool.java:626)
- locked< 0x00000007aed40048> (a org.mortbay.thread.QueuedThreadPool $ PoolThread)

26774405 @ qtp-393978767-9984prio = 10 tid = 0x00007f3ee4b37000 nid = 0x74e6在Object.wait()[0x0000000045d1a000]
java.lang.Thread.State:TIMED_WAITING(在对象监视器上)$ b $在java.lang.Object.wait(本地方法)
在org.mortbay.thread.QueuedThreadPool $ PoolThread.run(QueuedThreadPool。 java:626)
- 锁定< 0x00000007aed83aa0> (a)org.mortbay.thread.QueuedThreadPool $ PoolThread
$ b764808089 @ qtp-393978767-9983prio = 10 tid = 0x00007f3ee4c50000 nid = 0x74e5在Object.wait()[0x000000004ad6a000]
java.lang.Thread.State:TIMED_WAITING(在对象监视器上)$ b $在java.lang.Object.wait(本地方法)
在org.mortbay.thread.QueuedThreadPool $ PoolThread.run(QueuedThreadPool。 java:626)
- locked< 0x00000007aed5c448> (a org.mortbay.thread.QueuedThreadPool $ PoolThread)

所以,有很多线程 TIMED_WAITING 状态。理论上,这种情况在正常运行的应用程序中很容易找到(应用程序目前没有任何传入请求),但是我找不到任何单个请求分派线程执行一些有用的操作(名义命中率大约为100 hps)。



这种行为是否与GC有关,或者它只是巧合? 解决方案回答只是问题的标题:


当JVM花费在GC上的时间时,线程转储是什么样子?


答案是:您无法获得此类转储(以常规方式)。



JVM只有在达到安全点
在GC中不会发生。



但是有一种欺骗方式可以在未记录的JVMT的帮助下获得活动GC的线程转储我在这篇文章中提到了AsyncGetCallTrace:

http://jeremymanson.blogspot.com/2010/07/why-many-profilers-have-serious.html



它还暗示 Oracle Solaris Studio 可以 使用混合的native / java线程转储。


When profiling Java application I note interesting fact. When JVM is in GC spiral of death thread dump is looks like:

"1304802943@qtp-393978767-9985" prio=10 tid=0x00007f3ed02dd000 nid=0x74e7 in Object.wait() [0x000000004febb000]
 java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:626)
    - locked <0x00000007aed40048> (a org.mortbay.thread.QueuedThreadPool$PoolThread)

"26774405@qtp-393978767-9984" prio=10 tid=0x00007f3ee4b37000 nid=0x74e6 in Object.wait() [0x0000000045d1a000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:626)
    - locked <0x00000007aed83aa0> (a org.mortbay.thread.QueuedThreadPool$PoolThread)

"764808089@qtp-393978767-9983" prio=10 tid=0x00007f3ee4c50000 nid=0x74e5 in Object.wait() [0x000000004ad6a000]
   java.lang.Thread.State: TIMED_WAITING (on object monitor)
    at java.lang.Object.wait(Native Method)
    at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:626)
    - locked <0x00000007aed5c448> (a org.mortbay.thread.QueuedThreadPool$PoolThread)

So, there are a lot of threads in TIMED_WAITING state. Theoretically this situation could be easily found in normally functioning application (application simply doesn't have any incoming requests at the moment), but I can't find even single request dispatching thread doing something useful (nominal hit rate is about 100 hps).

Does this behavior have something to di with GC, or it's just coincidence?

解决方案

Answering just the question's title:

What does thread dump look like when JVM spent time in GC?

The answer is: you have no means to obtain such dump (in a usual way).

JVM processes the request for thread dump only after reaching safepoint which just can't happen while in GC.

But there is a cheat way to obtain active GC's thread dump with help of undocumented JVMTI function AsyncGetCallTrace which is mentioned in this post:

http://jeremymanson.blogspot.com/2010/07/why-many-profilers-have-serious.html

It also hints that Oracle Solaris Studio can be used to take such mixed native/java thread dumps.

这篇关于JVM在GC中花费时间时线程转储是什么样的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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