2

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
osgx
  • 90,338
  • 53
  • 357
  • 513
  • May be [opagent](http://oprofile.sourceforge.net/doc/devel/index.html) for oprofile? – osgx Oct 02 '12 at 19:36
  • And for perf there was patch ["perf report: Add support for profiling JIT generated code"](http://lwn.net/Articles/474254/) by penberg@ to support Jato JVM's JIT via `/tmp/perf-$PID.map` symbol(?) file. Format is "Startaddr size name\n". This file must be readable by `perf report` – osgx Oct 03 '12 at 12:39
  • 1
    and here is the perf patch: https://lkml.org/lkml/2009/6/8/499 "perf report: Add support for profiling JIT generated code" – osgx May 31 '13 at 17:01
  • And for oprofile there is the support code: `llvm/lib/ExecutionEngine/OProfileJIT/OProfileWrapper.cpp` thanks to http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-March/060153.html – osgx Jul 12 '13 at 16:40

1 Answers1

3

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.

osgx
  • 90,338
  • 53
  • 357
  • 513
seacoder
  • 514
  • 5
  • 11
  • seacoder, thank you. What is the format of `/tmp/perf-$pid.map`? When does perf access it, in `record`, after `record` or in `report` subcommand? How can I have the disassembly of JIT-generated code? – osgx Oct 07 '14 at 16:00
  • 2
    The map files contains entries in the format of
    – seacoder Oct 07 '14 at 17:54
  • seacoder, I can access disassembly of the static machine code with perf report, but not of JIT-generated code. The code, made by JIT is deleted at time of perf report and copy of this machine code is not saved. – osgx Oct 07 '14 at 20:52
  • osgx, I have not attempted to disassemble JITed code using `perf`, so I will have to defer to the perf docs on that. – seacoder Oct 07 '14 at 20:57