用于Java应用程序的锁分析器 [英] Lock analyser for Java application
问题描述
我有两个版本的Java应用程序使用不同的并发逻辑。
我想分析并比较它们的性能(获取锁的时间等等)以便我可以使用更好的一个。
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.
我找到了一个IBM Lock Analyzer for Java工具,但它既不是开源的也不是JDK版本独立的。
它需要IBM®提供的Java™SDK或JRE。
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.
IBM的另一个工具是多核软件开发工具包,存在以下问题
Another tool also from IBM is Multicore Software Development Kit and has the following problem
< 除了锁定
分析工具外,MSDK
的测试和分析工具在Sun JDK上运行。性能工具
需要IBM JDK。
"The testing and analysis tool of MSDK runs on Sun JDK, except the lock analysis tool. The performance tool requires an IBM JDK."
那么有人可以推荐任何适用于Sun / Oracle Java的锁分析工具吗?
So can anybody recommend any such lock analysis tool which works with Sun/Oracle Java?
推荐答案
这是一个技巧,我已经多次使用命令行在生产环境中找到锁争用:
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 是一个很好的商业选择。
YourKit is a good commercial option.
这篇关于用于Java应用程序的锁分析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!