Recently we started stress testing our application (an XMPP based chat server) using YJP 11.0.9. During our test we noticed following strange behavior.
- Sampling shows sun.misc.Unsafe.unpark(Object) took 60% of CPU.
- For the same app Tracing shows that LockSupport.park(Object) took 52% of CPU.
I did multiple tests to confirm results and every time I got similar results.
I am unable to understand why unpark should take 60% time and why tracing shows exactly opposite results.
Can someone help me understand these results. Am I missing something here?
Environment:
java -version java version "1.6.0_31" Java(TM) SE Runtime Environment (build 1.6.0_31-b04) Java HotSpot(TM) 64-Bit Server VM (build 20.6-b01, mixed mode)
unpark
is pretty much the only thing the thread ever does. What do you mean that "tracing shows exactly opposite results"? Does tracing perhaps measure time spent within a method?park
is a blocking method, so no wonder time is spent within it. – Yoshieyoshikounpark
is not the thread being unparked. That thread, in turn, may really only be doing little work besides unparking the appropriate consumer threads. As for the CPU time ofpark
, it is a) tough to measure due to blocking and b) irrelevant since it will be an insignificant fraction of the actual time spent in the parked state. – Yoshieyoshikounpark
only.park
cannot be a problem. Also, I don't know what exactly you mean by "during sampling" and "during tracing". JVisualVM, for example, has a sampling profiler, it shows hot spots while running. They are largely irrelevant. The really relevant stuff is shown after taking a snapshot and analyzing each thread's call stacks. – Yoshieyoshiko