Ubuntu 16.04 LTS - 如何为 perf 工具启用符号
Ubuntu 16.04 LTS - How to enable symbols for the perf tool
我正在尝试为我的应用程序收集一些分析数据,并且我 运行 为此使用了 perf 工具和火焰图。
我指的是此幻灯片共享中提供的说明:https://www.slideshare.net/brendangregg/java-performance-analysis-on-linux-with-flame-graphs
下面是我运行宁的命令:
1. sudo perf record -F 997 -a -g
2. sudo perf script > out.stacks01
当我 运行 第二个命令时,它显示以下消息:
Failed to open /tmp/perf-9931.map, continuing without symbols.
no symbols found in <some path>, maybe install a debug package?
我进行了一些在线浏览并尝试按照此处所述安装调试包:https://gist.github.com/NLKNguyen/2fd920e2a50fd4b9701f
然而,当我运行"sudo apt-get update"时,它最终失败说"Failed to fetch......"
有人能知道这是怎么回事吗?我需要做什么才能正确安装调试符号包?
编辑:
我的关键问题是我生成的火焰图里面没有 Java 符号,因此我最终专注于上面的 errors/messages。下面接受的答案为我原来的 post 提供了很好的解释。但是,我能够通过 运行ning jmaps 解决我的问题,如下所示:
sudo perf record -F 997 -a -g -- sleep 300; jmaps
上面共享的幻灯片 link 中的说明中记录了这一点。
当不兼容性能分析代理 运行。
In http://www.brendangregg.com/perf.html#JIT_Symbols there is recommendation "Java can do this with perf-map-agent" to use https://github.com/jvm-profiling-tools/perf-map-agent 将为 perf:
生成映射文件
Architecture
Linux perf tools will expect symbols for code executed from unknown
memory regions at /tmp/perf-.map. This allows runtimes that
generate code on the fly to supply dynamic symbol mappings to be used
with the perf suite of tools.
perf-map-agent is an agent that will generate such a mapping file for
Java applications. It consists of a Java agent written C and a small
Java bootstrap application which attaches the agent to a running Java
process.
When the agent is attached it instructs the JVM to report code blobs
generated by the JVM at runtime for various purposes. Most
importantly, this includes JIT-compiled methods but also various
dynamically-generated infrastructure parts like the dynamically
created interpreter, adaptors, and jump tables for virtual dispatch
(see vtable and itable entries). The agent creates a
/tmp/perf-.map file which it fills with one line per code blob
that maps a memory location to a code blob name.
The Java application takes the PID of a Java process as an argument
and an arbitrary number of additional arguments which it passes to the
agent. It then attaches to the target process and instructs it to load
the agent library.
并且在 https://www.slideshare.net/brendangregg/java-performance-analysis-on-linux-with-flame-graphs 中,Gregg 使用了 OpenJDK 的特殊破解版 - 幻灯片 36 - “-XX:+PreserveFramePointer
• 我破解了 OpenJDK x86_64 以支持帧指针”。
从幻灯片 41 Gregg 谈到 /tmp/perf-*.map
个文件:
Fixing Symbols
• For JIT'd code, Linux perf already looks for an externally provided symbol file: /tmp/perf-PID.map, and warns if it doesn't exist
• This file can be created by a Java agent
# perf script
Failed to open /tmp/perf-8131.map, continuing without symbols
(还有 "See lkml for "perf:添加对分析 jitted 代码的支持"" - https://lwn.net/Articles/633846/ 和其他)
我正在尝试为我的应用程序收集一些分析数据,并且我 运行 为此使用了 perf 工具和火焰图。
我指的是此幻灯片共享中提供的说明:https://www.slideshare.net/brendangregg/java-performance-analysis-on-linux-with-flame-graphs
下面是我运行宁的命令:
1. sudo perf record -F 997 -a -g
2. sudo perf script > out.stacks01
当我 运行 第二个命令时,它显示以下消息:
Failed to open /tmp/perf-9931.map, continuing without symbols.
no symbols found in <some path>, maybe install a debug package?
我进行了一些在线浏览并尝试按照此处所述安装调试包:https://gist.github.com/NLKNguyen/2fd920e2a50fd4b9701f
然而,当我运行"sudo apt-get update"时,它最终失败说"Failed to fetch......"
有人能知道这是怎么回事吗?我需要做什么才能正确安装调试符号包?
编辑: 我的关键问题是我生成的火焰图里面没有 Java 符号,因此我最终专注于上面的 errors/messages。下面接受的答案为我原来的 post 提供了很好的解释。但是,我能够通过 运行ning jmaps 解决我的问题,如下所示:
sudo perf record -F 997 -a -g -- sleep 300; jmaps
上面共享的幻灯片 link 中的说明中记录了这一点。
In http://www.brendangregg.com/perf.html#JIT_Symbols there is recommendation "Java can do this with perf-map-agent" to use https://github.com/jvm-profiling-tools/perf-map-agent 将为 perf:
生成映射文件Architecture
Linux perf tools will expect symbols for code executed from unknown memory regions at /tmp/perf-.map. This allows runtimes that generate code on the fly to supply dynamic symbol mappings to be used with the perf suite of tools.
perf-map-agent is an agent that will generate such a mapping file for Java applications. It consists of a Java agent written C and a small Java bootstrap application which attaches the agent to a running Java process.
When the agent is attached it instructs the JVM to report code blobs generated by the JVM at runtime for various purposes. Most importantly, this includes JIT-compiled methods but also various dynamically-generated infrastructure parts like the dynamically created interpreter, adaptors, and jump tables for virtual dispatch (see vtable and itable entries). The agent creates a /tmp/perf-.map file which it fills with one line per code blob that maps a memory location to a code blob name.
The Java application takes the PID of a Java process as an argument and an arbitrary number of additional arguments which it passes to the agent. It then attaches to the target process and instructs it to load the agent library.
并且在 https://www.slideshare.net/brendangregg/java-performance-analysis-on-linux-with-flame-graphs 中,Gregg 使用了 OpenJDK 的特殊破解版 - 幻灯片 36 - “-XX:+PreserveFramePointer
• 我破解了 OpenJDK x86_64 以支持帧指针”。
从幻灯片 41 Gregg 谈到 /tmp/perf-*.map
个文件:
Fixing Symbols
• For JIT'd code, Linux perf already looks for an externally provided symbol file: /tmp/perf-PID.map, and warns if it doesn't exist • This file can be created by a Java agent
# perf script Failed to open /tmp/perf-8131.map, continuing without symbols
(还有 "See lkml for "perf:添加对分析 jitted 代码的支持"" - https://lwn.net/Articles/633846/ 和其他)