Understanding CPU time in visualvm profiler

白昼怎懂夜的黑 提交于 2019-12-07 05:26:25

问题


I have started to use visualvm for profiling my application which I launch in Eclipse. Then I launch visualvm which initially gives believable results.

After some time two processes appear in the monitor which consume huge amounts of time.

I have not deliberately invoked these. After a time they disappear. Are they an artefact of the profiling process and do I need to worry?

Very few of my routines appear in the profile, mainly the libraries they call. Is there a way of showing which routines call the most heavily used ones?


回答1:


It is better to start with CPU sampling, if you don't know which part of the code is slow. Once you know better (based on the sampling results) what is going on, you can profile just part of your application, which is slow. You need to set profiling roots and instrumentation filter and don't forget to take the snapshot of collected results. See Profiling With VisualVM, Part 1 and Profiling With VisualVM, Part 2 to get more information about profiling and how to set profiling roots and instrumentation filter.




回答2:


VisualVM uses Java to perform it's work. This means you will see some artefacts which relate to the RMI calls it makes. You can ignore them.

I use YourKit which doesn't do this, but it's not free ;)




回答3:


VisualVM will track all methods being called by the java program it's monitoring, so either your program or one of its libraries is calling those methods. VisualVM is also connecting to it so there might be some small artifacts.

As for searching, probably the easiest way is to filter by your own packages. There is a space at the bottom where you can enter those so you can see which of your own methods is really taking time. Also you should pay attention to which thread you are in, usually you will want to look at the whatever is your "main" thread. The other threads are interesting but won't always give you the best idea of how your program behaves.



来源:https://stackoverflow.com/questions/17049172/understanding-cpu-time-in-visualvm-profiler

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