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

time to generate map file #84

Closed navyxliu closed 4 years ago

navyxliu commented 4 years ago

Hello, Authors, Thank you to open-source this projects. The agent and handy scripts are extremely helpful for me.

I have a problem about JIT-ed code. I end up with a lot of PCs which point to nowhere but fall in the range of map files. I interpret it in this way: the symbols in the map file are not accurate.

I have a question about this line. It seems that two statements happen in sequence. https://github.com/jvm-profiling-tools/perf-map-agent/blob/d9843a011f76c4edf5f3d7fe84dd513bc6422686/bin/perf-java-record-stack#L25

That is to say, the script generates map file right after 'perf record' has done. Why not make them run in parallel? In current model, will agent has a skewed view? or I have to make sure my profiling program enter a stable state ?

jrudolph commented 4 years ago

It works indeed best in steady state. The problem is otherwise that a profiling run takes some time but we can only provide a single map file which contains a snapshot of the current mappings. If anything changes during the profiling run that snapshot would not be current.

27 has some ideas how mapping could work if new entries are written during the whole lifetime of the process but afaik no one has looked into what would be needed to output the required format.

If the mapping itself is correct but somewhat inaccurate adding -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints parameters can help as well.

Alternatively, I often use async-profiler if I need to profile non-steady state JVMs.

navyxliu commented 4 years ago

@jrudolph thank you! I got it. you are right. Actually, I run dacapo benchmark. I manage to skip many warmup iterations and the results become more reasonable. meanwhile, let me try to use async-profiler.