Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Missing JAVA Procedure names in Time Profiler, Instruments, OS X

I am writing an algorithm implementation using Java. Until OS X 10.7, I used the Shark Profiler to profile my implementation, which worked rather nicely. However, the new Instruments does not find the procedure names anymore. I already tried running the java application with the VM arguments for shark (namely, -agentlib:Shark ), but they are unknown to 10.7, and I couldn't find such an agentlib for instruments.

Any idea on how I can attach procedure names to the symbol names (which are some hex numbers) in Insturments? I am using Eclipse Indigo, if that makes any difference.

Thanks!

Edit: So far, nothing has changed with OS X Mountain Lion.

Edit #2: An update from a (?) developer via apple's bug reporter:

dtrace has had support for Java stacks at points in the past, though I honestly couldn't say whether the support has been maintained. It may be a viable workaround for what you're trying to measure – which is otherwise not a priority for the performance tools at this point. You may want to start with the D script in /usr/bin/cpu_profiler.d and amend it to collect the jstack as well.

Edit #3: Alright, after some more discussion it turns out that the developer himself didn't know where that script came from. Apparantly, the time profiler in Instruments doesn't use DTrace anyhow, so the only option left is to write our own DTrace script or instrument.

You're right, and I apologize. I'm not sure where that script came from, and when I looked at it carefully, it doesn't have jstack actions in it so it's not what you want anyway. It looks like the only java profiling option I can offer you is DTrace. DTrace has a profile provider, and a jstack action that collects java stacks. You can use "aggregates" to determine the heaviest stack traces, and all of this works from the command line. The documentation for DTrace is mostly maintained by Sun and I'd direct you to any DTrace tutorial since most cover the profile provider.

Despite what people say online, Instruments does not use DTrace for everything, specifically time profiling, so I can't offer you a quick fix in the Instruments UI.

like image 640
HdM Avatar asked Dec 09 '11 13:12

HdM


1 Answers

Instruments relies upon a bit of lovely software developed by Sun called dtrace. dtrace has a function called 'jstack()' that is supposed to print a stack trace with java symbols, there is also a 'ustack()' that is supposed to do similar things for other langauges (python, node.js, etc.). Unfortunately OS X's version of dtrace does not support those methods and as such Instruments won't provide that functionality.

So, unfortunately you're not going to get that information from those tools until Apple fixes their stuff. :(

Follow this thread for more info: http://www.mail-archive.com/[email protected]/msg04863.html

I've filed a bug with apple regarding their lack of support for helper stack tracers, if you want this functionality you should file a bug too: https://bugreport.apple.com

like image 88
Alpha Fighter Avatar answered Nov 02 '22 09:11

Alpha Fighter