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.64k stars 260 forks source link

cannot print method defined by user program #55

Closed ufo19890607 closed 5 years ago

ufo19890607 commented 7 years ago

Really a newbie question

When I use the agent on a perf record command line and then run perf report, I just see some built-in methods ,like System.out.prinln, but it does not print other methods ,such as , "main, print_rectangle(a user-defining method which just prints some "*")". I follow the steps on your your blog Java in Flames ( 1. install perf-map-agent , 2. profiling and flame graph generation:).

When I run perf record -F 49 -a -g -- sleep 30; ./FlameGraph/jmaps , I see the perf-5084.map file. The perf report shows some unknown info: Samples: 331 of event 'cycles', Event count (approx.): 3811883239
Children Self Command Shared Object Symbol ◆ -- 69.94% 0.00% java [unknown] [.] 0xb3f180e200026c80 ▒ -- 0xb3f180e200026c80 ▒ 81.85% 0 ▒ 18.15% 0x8000268d8 ▒ -- 69.13% 1.37% java perf-7341.map [.] Ljava/io/FileOutputSt▒ -- Ljava/io/FileOutputStream;::writeBytes ▒ ++ 81.75% Ljava/io/PrintStream;::print ▒ ++ 18.25% Lsun/nio/cs/StreamEncoder;::flushBuffer ▒ ++ 67.76% 0.00% java libjava.so [.] Java_java_io_FileOutp▒ ++ 66.79% 0.00% java libpthread-2.17.so [.] 0xffff80d8d849543d ▒ ++ 63.03% 6.52% java perf-7341.map [.] Ljava/io/PrintStream;▒ ++ 62.09% 0.00% java libjava.so [.] 0xffff80d8dabfe1f0 ▒ ++ 56.92% 0.00% java [unknown] [.] 0000000000000000 ▒ ++ 56.66% 0.69% java [kernel.kallsyms] [k] sys_write ▒ ++ 56.30% 0.00% java [kernel.kallsyms] [k] system_call_fastpath ▒ ++ 51.99% 1.85% java [kernel.kallsyms] [k] vfs_write

My java version is 1.8.0.131. And up to date perf-map-agent repo~

nitsanw commented 7 years ago

This is part of the limitations of the tool:

Inlining and recompilation of methods naturally occur as part of the application lifetime as different methods compile and recompile to reflect how hot they are or the changing assumptions the JVM can make. Inlining results in larger and larger methods. Compilations slow down to a trickle after sufficient "warmup", they do not stop (unless your CodeCache is full, which is not good). Profiling using perf-map-agent + perf will yield best (as in the most easily legible) results by being profiled and "mapped" after the warmup period has finished when the mapping is least dynamic and the important part of the code have fully settled. Profiling with "unfoldall" is made usable by feeding the collapsed stacks into the flamegraph script which breaks them back into a more readable state. So:

  1. Is the Java process running with PreserveFramePointer?
  2. Is the perf-map-agent running with unfoldall?
  3. Is the process sufficiently settled?

You may find that using async-profiler gives you good insight where the PMA+Perf combination is hard to use.