JDK-8316286 : Add diagnostic command to write Linux perf jit dump file
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: svc
  • Affected Version: 22
  • Priority: P5
  • Status: Open
  • Resolution: Unresolved
  • OS: linux
  • Submitted: 2023-09-14
  • Updated: 2023-11-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
We have `XX:+DumpPerfMapAtExit` and `jcmd Compiler.perfmap` to support profiling with linux perf. They dump symbols of code in CodeCache.

Linux perf supports jit dumps which it can inject into `perf.data`.
The format of the jit dump is specified here:
https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jitdump-specification.txt

We can have `XX:+DumpPerfJitDumpAtExit` and `jcmd Compiler.perfjitdump` to dump such files. The command should support:
- Dump all code heap (the default mode).
- Dump particular code heaps.
- The default dump file name: `jit-JVM_PID.dump`
- A dump file path.

Use case with `DumpPerfJitDumpAtExit`

$ java -XX:+UnlockDiagnosticVMOptions -XX:+DumpPerfJitDumpAtExit MyBenchmark
$ perf record -k mono -- sleep 60
$ perf inject --jit --input perf.data --output perf.jit.data
$ perf report -i perf.data.jitted

Use case with `jcmd Compiler.perfjitdump`

$ java -XX:+UnlockDiagnosticVMOptions MyServiceApp
$ jcmd <jvm_pid> Compiler.perfjitdump
$ perf record -k mono -- sleep 60
$ perf inject --jit --input perf.data --output perf.jit.data
$ perf report -i perf.data.jitted

It's possible to generate this already for Java processes using a linux perf JVMTI plugin: libperf-jvmti.so. However the plugin might not be available in a particular Linux distribution and will require to compile it from kernel sources. The plugin won't help when we want to log in to a host running a service and to dump a file without restarting the service.
It would be more convenient if Hotspot could write this file directly using a diagnostic command.

Resources:
https://lwn.net/Articles/638566/
https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/perf-inject.txt
https://github.com/torvalds/linux/blob/master/tools/perf/Documentation/jitdump-specification.txt