Search code examples
performanceprofilingvisualvm

How to explain inconsistencies between visualvm cpu sample and snapshot created from it?


I've used cpu sampler of visualvm to record a behavior of my application for the purpose of finding a performance bottleneck. I can see some interesting results in live hotspots view, but when i take a snapshot of from the live view for later work, hotspots in that snapshot is absolutely different. This picture explains it pretty well: http://tinypic.com/view.php?pic=auhx0j&s=6

How is this inconsistency possible? Maybe I don't understand what live view and snapshot is, can someone clarify it?


Solution

  • I was also looking for the reasoning why there are inconsistencies between the sampler and snapshot hot spots. Since I couldn't find an explanation here nor anywhere else I tried to figure it out myself.

    tl;dr

    It is most probable a bug in the visualization of the snapshot view because it seems to not fully respect the exclusion packages like sun.* and so on which are set by default when starting the sampler.

    How did I came to my conclusion?

    Well, I played with different package exclusion settings turning all off, some on and so forth and always looking at the sampler and snapshot view comparing them. Although I exclude the java.*, sun.* packages they still show up in the snapshot view but not in the sampler view. What I still don't get either is when I remove all package exclusions then snapshot and sampler views are identical what everybody would expect regardless of which packages are excluded.

    So far my two cents. Happy sampling!