RFR: 8254723: add diagnostic command to write Linux perf map file [v4]
Nick Gasson
ngasson at openjdk.java.net
Mon Oct 26 06:06:47 UTC 2020
> When using the Linux "perf" tool to do system profiling, symbol names of
> running Java methods cannot be decoded, resulting in unhelpful output
> such as:
>
> 10.52% [JIT] tid 236748 [.] 0x00007f6fdb75d223
>
> Perf can read a simple text file format describing the mapping between
> address ranges and symbol names for a particular process [1].
>
> It's possible to generate this already for Java processes using a JVMTI
> plugin such as perf-map-agent [2]. However this requires compiling
> third-party code and then loading the agent into your Java process. It
> would be more convenient if Hotspot could write this file directly using
> a diagnostic command. The information required is almost identical to
> that of the existing Compiler.codelist command.
>
> This patch adds a Compiler.perfmap diagnostic command on Linux only. To
> use, first run "jcmd <pid> Compiler.perfmap" and then "perf top" or
> "perf record" and the report should show decoded Java symbol names for
> that process.
>
> As this just writes a snapshot of the code cache when the command is
> run, it will become stale if methods are compiled later or unloaded.
> However this shouldn't be a big problem in practice if the map file is
> generated after the application has warmed up.
>
> [1] https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jit-interface.txt
> [2] https://github.com/jvm-profiling-tools/perf-map-agent
Nick Gasson has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains four commits:
- Merge master
- Add -XX:+DumpPerfMapAtExit option
- Update for review comments
- 8254723: add diagnostic command to write Linux perf map file
When using the Linux "perf" tool to do system profiling, symbol names of
running Java methods cannot be decoded, resulting in unhelpful output
such as:
10.52% [JIT] tid 236748 [.] 0x00007f6fdb75d223
Perf can read a simple text file format describing the mapping between
address ranges and symbol names for a particular process [1].
It's possible to generate this already for Java processes using a JVMTI
plugin such as perf-map-agent [2]. However this requires compiling
third-party code and then loading the agent into your Java process. It
would be more convenient if Hotspot could write this file directly using
a diagnostic command. The information required is almost identical to
that of the existing Compiler.codelist command.
This patch adds a Compiler.perfmap diagnostic command on Linux only. To
use, first run "jcmd <pid> Compiler.perfmap" and then "perf top" or
"perf record" and the report should show decoded Java symbol names for
that process.
As this just writes a snapshot of the code cache when the command is
run, it will become stale if methods are compiled later or unloaded.
However this shouldn't be a big problem in practice if the map file is
generated after the application has warmed up.
[1] https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jit-interface.txt
[2] https://github.com/jvm-profiling-tools/perf-map-agent
-------------
Changes: https://git.openjdk.java.net/jdk/pull/760/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=760&range=03
Stats: 171 lines in 8 files changed: 169 ins; 1 del; 1 mod
Patch: https://git.openjdk.java.net/jdk/pull/760.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/760/head:pull/760
PR: https://git.openjdk.java.net/jdk/pull/760
More information about the serviceability-dev
mailing list