Lock analyser for Java application

余生颓废 提交于 2019-12-21 05:27:10

问题


I have two versions of a Java application which use different concurrency logic.
I want to analyze and compare their performance (such amount of time a lock was acquired etc.) so that I can use the better one.

I found out a tool IBM Lock Analyzer for Java but it is neither open source nor JDK version independent.
It requires an IBM®-supplied Java™ SDK or JRE.

Another tool also from IBM is Multicore Software Development Kit and has the following problem

"The testing and analysis tool of MSDK runs on Sun JDK, except the lock analysis tool. The performance tool requires an IBM JDK."

So can anybody recommend any such lock analysis tool which works with Sun/Oracle Java?


回答1:


Here's a trick I've used a number of times to find lock contention in production environments from the command line:

watch -n1 'jstack [pid] | grep -A 1 BLOCKED | grep -v BLOCKED | grep -v \\-\\-'

Not only is it free, there's virtually no overhead. It won't give you stats or a nice UI of course, however it makes real-time locking issues obvious in a visual way. Essentially this is sampling every second to find blocked threads. With enough server load you should be able to make a comparison.

YourKit is a good commercial option.



来源:https://stackoverflow.com/questions/5390317/lock-analyser-for-java-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!