简体   繁体   English

在OpenJDK JVM上运行cachegrind

[英]Running cachegrind on OpenJDK JVM

I want to use cachegrind to do some performance profiling on the OpenJDK JVM. 我想使用cachegrind在OpenJDK JVM上进行一些性能分析。 (BTW, if this is Not A Good Idea, I would like to understand why.) (顺便说一句,如果这不是一个好主意,我想知道为什么。)

The problem is it keeps tripping up assertions in the JVM. 问题在于它会不断触发JVM中的断言。 So what can I do to get a run using cachegrind. 所以我该怎么做才能使用cachegrind运行。 Or else, please tell me why this wouldn't work. 否则,请告诉我为什么这行不通。 And if you can suggest an alternative to cachegrind. 并且,如果您可以建议使用cachegrind的替代方法。 (Note that I have looked at and used perf. It's just that I was curious how different a tool like cachegrind/callgrind would be in terms of results.) (请注意,我已经研究并使用过perf。只是我很好奇像cachegrind / callgrind这样的工具在结果方面的差异。)

Valgrind and the tools based on it are typically not very good for performance profiling. Valgrind及其基于它的工具通常不适合性能分析。 Valgrind is a kind of a virtual machine that does not execute the original code directly but rather translates it. Valgrind是一种虚拟机,它不直接执行原始代码,而是对其进行翻译。 Programs often run much slower under Valgrind, and this can affect the application execution scenario. 在Valgrind下,程序运行速度通常会慢得多,这可能会影响应用程序的执行情况。

Also Valgrind does not work well with the dynamic and self-modifying code. 而且Valgrind不能很好地与动态和自修改代码配合使用。 With respect to JVM's JIT compilation this can result in random assertion failures and JVM crashes that you apparently observe. 关于JVM的JIT编译,这可能会导致随机断言失败,并且您显然会观察到JVM崩溃。 Valgrind is known to be much more stable when Java is run with JIT disabled, ie -Xint . 当Java在禁用JIT的情况下(即-Xint )运行时,Valgrind更加稳定。 But in -Xint mode profiling does not make much sense since it does not reflect the real application performance. 但是,在-Xint模式下进行性能分析没有多大意义,因为它不能反映实际的应用程序性能。

perf is preferable way to do this kind of measurements. perf是进行此类测量的首选方法。 perf relies on hardware counters, it does not modify the executed code. perf依靠硬件计数器,它不修改执行的代码。 For deeper performance analyis there is Intel VTune Amplifier. 要进行更深入的性能分析,请使用英特尔VTune放大器。 It is not free though, but a trial version is available. 虽然它不是免费的,但是可以使用试用版。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM