Java Mission Control 说“很少有分析样本",为什么以及我的其他选择是什么? [英] Java Mission Control says "few profiling samples", why, and what are my other options?

查看:49
本文介绍了Java Mission Control 说“很少有分析样本",为什么以及我的其他选择是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Java Mission Control 分析 Java 应用程序,飞行记录的主页上说即使 CPU 负载很高,此记录也包含很少的分析样本.因此,分析数据可能不相关."

I'm profiling a Java application using Java Mission Control, and it's saying on the main page of the flight recording that "This recording contains few profiling samples even though CPU load is high. The profiling data is thus likely not relevant."

这似乎是实话.我要求它每 10 毫秒采样 3 分钟,应该是 18000 个样本,但我只看到 996 个样本.

It seems to be telling the truth. I asked it to sample every 10 ms for 3 minutes which should be 18000 samples, but I only see 996 samples.

它继续解释因此分析数据可能不相关.这可能是因为应用程序运行了大量 JNI 代码,或者 JVM 在 GC、类加载、JIT 编译等方面花费了大量时间."

It goes on to explain "The profiling data is thus likely not relevant. This might be because the application is running a lot JNI code or that the JVM is spending a lot of time in GC, class loading, JIT compilation etc."

嗯,我没有任何本地方法,它不应该在我记录的阶段加载类或执行任何 JIT(很好地进入代码的重复数字运算部分.)它看起来不像它也花费了过多的时间进行垃圾收集.

Hmm, I don't have any native methods, and it shouldn't be loading classes or doing any JIT at the stage I recorded (well into the repetitive number crunching part of the code.) It doesn't look like it's spending an inordinate amount of time garbage collecting either.

我们曾经使用 hprof 来分析这个产品,并取得了很大的成功.Hprof 极大地帮助我们确定了我们在哪里依赖主线程执行,因此我们可以将热点并行化为多个线程.但是该工具在 Java 9 中已停止使用,因此我们将转向 Java Mission Control.它有很多用途,但是如果它无法识别 VM 线程在随机采样时间所在的行号,则它不是很有用.还有其他工具可以使用吗?或者,有没有办法在 Java Mission Control 中进一步调试?看起来 JVisualVM 也不再包含在 Java 9 中.

We used to use hprof to profile this product, with much success. Hprof helped immensely in figuring out where we were relying on the main thread execution, so we could parallelize the hotspots into multiple threads. But that tool got discontinued in Java 9 so we're moving onward to Java Mission Control. It has a lot going for it, but if it can't identify what line numbers the VM threads are sitting on at random sample times, it's not very useful. Is there some other tool to use? Or, is there a way to debug this further from within Java Mission Control? It also looks like JVisualVM is no longer included in Java 9.

推荐答案

答案可能很简单,因为线程数多于内核数,因此大多数线程在采样时并未在 CPU 上进行调度.JFR 方法采样器只会在 CPU 上实际保留线程样本.这个想法是为您提供一个视图,了解您实际花费时间执行 Java 代码的位置.

The answer is probably as simple as you having more threads than cores, and thus most of them not being scheduled on CPU at the time of sampling. The JFR method sampler will only keep samples of threads actually on CPU. The idea is to provide you of a view of where you are actually spending the time executing your Java code.

现在,我们知道在某些情况下,您希望获得所有线程的随机样本,无论它们在做什么.我们正在 JDK 10 中添加新的分析功能/事件.

Now, we know that there are cases where you want to get random samples of all threads, no matter what they are doing. We are adding new profiling capabilities/events in JDK 10.

这篇关于Java Mission Control 说“很少有分析样本",为什么以及我的其他选择是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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