inaccurate timing of native method calls

Questions about YourKit Java Profiler
Gibson
Posts: 181
Joined: Mon Apr 11, 2005 10:38 am

Re: inaccurate timing of native method calls

Post by Gibson »

Tested with Java SE 7u3 and JRockit 1.6.0_29, same problem everywhere, i.e. StrictMath.doLog is showing between 50% and 90% of CPU usage when it's actually only using about 30%.

(When using JRockit I get an extra error message "Unknown command memleakserver" at the end of the process but snapshots are dumped OK.)

By the way, I don't think StrictMath methods are intrinsic in either VM, but maybe I'm wrong, I haven't looked at the source code.
HTH,
R
jsravn
Posts: 3
Joined: Thu Dec 23, 2010 5:58 pm

Re: inaccurate timing of native method calls

Post by jsravn »

No offense to the yourkit guys, but you seriously underrepresent this limitation in documentation. Many seasoned devs have completely discounted yourkit because of it. It's pretty terrible wasting half a day fixing a yourkit hotspot to discover it actually had no real world impact (as OP discovered). After this happens a few dozen times, it gets old.

Have you guys contacted Oracle directly to request more accurate sampling from jvmti? Have you looked into using something like AsyncGetStackTrace that the old sun profiler used? There's gotta be a better way. I don't appreciate the attitude of "we can't do anything about it" for a fundamental part of your tool.
Vladimir Kondratyev
Posts: 1624
Joined: Tue Aug 10, 2004 7:52 pm

Re: inaccurate timing of native method calls

Post by Vladimir Kondratyev »

AsyncGetStackTrace is a non-existing API. It was removed (back in 2003) from JVMTI because it never worked good. At the moment there is no quick (and even dirty) solution to fix this issue.
Gibson
Posts: 181
Joined: Mon Apr 11, 2005 10:38 am

Re: inaccurate timing of native method calls

Post by Gibson »

The inaccuracies come from the fact that stack traces taken through JVMTI can only show code that has reached a safepoint in the VM. See this blog post for a brief overview. The author has released some proof-of-concept code for a high-precision profiler based on AsyncGetCallTrace (i.e. OpenJDK only) under an Apache licence which you can find here if you are interested.
Anton Katilin
Posts: 6172
Joined: Wed Aug 11, 2004 8:37 am

Re: inaccurate timing of native method calls

Post by Anton Katilin »

Thanks for the links. We'll take a look.
Gibson
Posts: 181
Joined: Mon Apr 11, 2005 10:38 am

Re: inaccurate timing of native method calls

Post by Gibson »

Java Flight Recorder doesn't seem to suffer from this problem as it doesn't need to be at a safepoint to get a stack sample. After testing, it seems to give me much more accurate results in this situation. (It does require adding the options -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints and of course it requires an additional license for production use.)
http://hirt.se/blog/?p=609
Post Reply