Search code examples
linuxprofilingjitoprofileperf

Profiling output of JIT on Linux with perf_events/oprofile?


I want to profile code, generated by JIT on Linux, with using hardware performace counters. As I know, most common profilers are oprofile and perf.

How can I integrate JIT and oprofile/perf?

My JIT is not JAVA which is already supported in oprofile. (perf?)

For example we can consider LLVM's JIT. I want to

  1. See the hottest functions (their names) from JIT-ted code
  2. See the disassembly of hottest function, with performance counter statistics assigned to every instruction

Solution

  • To profile JITed code using perf, download, compile and install the perf-map-agent library, then (for java code anyway) add the -agentpath:<path>/libperfmap.so to the command line.

    For non-java code, as long as the /tmp/perf-$pid.map symbol map files are generated, perf will use those when it produces perf reports.

    Brendan Gregg has a blog post that has related references.