jvm-profiling-tools / perf-map-agent

A java agent to generate method mappings to use with the linux `perf` tool
GNU General Public License v2.0
1.65k stars 260 forks source link

annotate a JITted method #7

Open tdeneau opened 9 years ago

tdeneau commented 9 years ago

Possible newbie question...

When I use the agent on a perf record command line and then run perf report, I do indeed see the JITted methods listed with event percentages, etc. But when I hit RETURN and try to drill down into a JITted method, no code is shown.

jrudolph commented 9 years ago

You are right that's currently not possible.

Last time I looked into it the perf-tools had a hard-coded way of disassembling binaries to do the annotations. It calls objdump <options> <library.so> with some parameters to create the disassembly and then annotates that. This obviously won't work for JITted methods which aren't persisted to disk.

I once had a hack in place where I provided an alternative objdump in the PATH which filters through the JVM's PrintAssembly output to provide drilling down into methods. However, the setup was very fragile so that I guess we'd need something better than that to make it actually work.

jrudolph commented 9 years ago

I've got a prototype of this working. This was quite a ride and will probably not be particularly portable but for me it works:

screenshot from 2014-12-06 11 30 43

Change upcoming after a bit of cleanup.

tdeneau commented 9 years ago

cool, will definitely give it a try when it is ready…

From: Johannes Rudolph [mailto:notifications@github.com] Sent: Saturday, December 06, 2014 4:33 AM To: jrudolph/perf-map-agent Cc: Deneau, Tom Subject: Re: [perf-map-agent] annotate a JITted method (#7)

I've got a prototype of this working. This was quite a ride and will probably not be particularly portable but for me it works:

[screenshot from 2014-12-06 11 30 43]https://cloud.githubusercontent.com/assets/9868/5327081/7519b70c-7d3b-11e4-802f-e0cae03ec8f3.png

Change upcoming after a bit of cleanup.

— Reply to this email directly or view it on GitHubhttps://github.com/jrudolph/perf-map-agent/issues/7#issuecomment-65892461.

tdeneau commented 9 years ago

Hi Johannes --

I have not been following the perf-map-agent project for a little while but I notice now a lot of things changed in December 2014. Is it supposed to still be possible to use perf record java -agentpath:libperfmap.so xxxx and then use perf report

Strangely even when I back up to the version before the December changes I cannot get this to work any longer. But then my kernel and perf tools might have changed since it last worked, I noticed my perf version is 3.15. (kernel is 3.17.0-0.1.fc22.aarch64)

-- Tom

From: Johannes Rudolph [mailto:notifications@github.com] Sent: Saturday, December 06, 2014 4:33 AM To: jrudolph/perf-map-agent Cc: Deneau, Tom Subject: Re: [perf-map-agent] annotate a JITted method (#7)

I've got a prototype of this working. This was quite a ride and will probably not be particularly portable but for me it works:

[screenshot from 2014-12-06 11 30 43]https://cloud.githubusercontent.com/assets/9868/5327081/7519b70c-7d3b-11e4-802f-e0cae03ec8f3.png

Change upcoming after a bit of cleanup.

— Reply to this email directly or view it on GitHubhttps://github.com/jrudolph/perf-map-agent/issues/7#issuecomment-65892461.

jrudolph commented 9 years ago

You don't need the -agentpath any more. Instead, there's now a small Java attach program which attaches the agent at runtime and report the current snapshot of JITted methods. See the perf-java script for how to use it.

jrudolph commented 8 years ago

If you want to play with it: I pushed a branch to https://github.com/jrudolph/perf-map-agent/pull/29 which works for me but still sometimes crashes the JVM and sometimes also perf.