JDK-8316922 : Add file name parameter to Compiler.perfmap
  • Type: CSR
  • Component: hotspot
  • Sub-Component: svc
  • Priority: P5
  • Status: Closed
  • Resolution: Withdrawn
  • Fix Versions: tbd
  • Submitted: 2023-09-25
  • Updated: 2023-12-01
  • Resolved: 2023-12-01
Related Reports
CSR :  
Description
Summary
-------

Extend `jcmd Compiler.perfmap` with an optional option `filename` to create a symbol mappings file for the linux perf different from the default `/tmp/perf-%d.map`. 

Problem
-------

The current implementation of `jcmd Compiler.perfmap` writes the perf map to a hard-coded file name: `/tmp/perf-%d.map` where `%d` is a java process ID. The hard-coded file name is inconvenient for long running applications where symbol mappings change because of code changes in CodeCache. These changes must be reflected in the perf map file before any run of `perf record`. If  we run `perf record` multiple times, we must preserve the previously created perf map file before each of the runs. Otherwise the perf map file will be overwritten and perf report will be incorrect. A workaround is to rename the previously created  map file before running perf record. With an ability to specify a filename, we would not need the workaround.

Solution
--------

`PerfMapDCmd` will inherit from `DCmdWithParser` to accept an additional argument `filename` which is optional. If it is provided, the perf map will be written to the specified filename. Otherwise, the perf map file will be written to `/tmp/perf-%d.map` where `%d` is a java process ID.

Specification
-------------

- `jcmd Compiler.perfmap` is unchanged and creates `/tmp/perf-%d.map`.
- `jcmd Compiler.perfmap <file>` creates the map file at the specified `<file>`.
- `jcmd PID help Compiler.perfmap` provides the following usage.

```
Compiler.perfmap [arguments] (Linux only)
       Write map file for Linux perf tool.
       
Impact: Low

       arguments:

       • filename: (Optional) Name of the map file (STRING, no default value)

       If filename is not specified, a default file name is chosen using the pid of the tar 
       get JVM process.  For example, if the pid is 12345, then the default filename will be
       /tmp/perf-12345.map.
```
Comments
[~cjplummer] My apologies. Since then I was reminded that we don't need one. I will update the PR.
30-11-2023

[~dholmes] But you requested a CSR in the PR: https://github.com/openjdk/jdk/pull/15871#issuecomment-1730731221
29-11-2023

We do not require a CSR request and review for changes to jcmd/dcmd options as they are deemed to be part of a diagnostic interface.
29-11-2023

[Chris Plummer](https://bugs.openjdk.org/secure/ViewProfile.jspa?name=cjplummer) Thanks, it looks good to me.
28-11-2023

[~yftsai] I made some updates. Let me know if they are ok and then I'll mark the CSR as reviewed.
28-11-2023

Thanks for pointing out. This case seems to be similar to the optional argument `filename` of jcmd `VM.cds`.
21-11-2023

I have some concerns about how the filename argument is specified, and how this compares to other jcmds. GC.heap_dump also has a filename argument, but the only way to specify it is by just including the filename on the command line. If you do filename=foo, it doesn't work properly and ends up dumping to "filename". Your syntax seems to be the opposite. filename=foo works, but just specifying the fllename gives an "Unkown argument" error. Also, your help refers to filename as option whereas GC.heap_dump refers to it as an argument. As an option, the following help text does not make much sense: Options: (options must be specified using the <key> or <key>=<value> syntax) filename : [optional] Name of the map file (STRING, no default value) The intent of using just `<key>` is for options like: -all : [optional] Dump all objects, including unreachable objects (BOOLEAN, false) Which can be specified as `-all` or `-all=true`. `filename` only supports the later syntax.
21-11-2023

[~yftsai] Please include the help output in the Specification section.
21-11-2023

[Chris Plummer](https://bugs.openjdk.org/secure/ViewProfile.jspa?name=cjplummer), [Serguei Spitsyn](https://bugs.openjdk.org/secure/ViewProfile.jspa?name=sspitsyn), may you help reviewing this CSR?
17-11-2023

Moving to Provisional, not Approved. [~yftsai], please have one or more engineers who work on jcmd review the CSR before it is Finalized for the second phase of CSR review.
30-10-2023

Moving back to Draft. [~yftsai], please completely fill out the CSR form and optionally get one or more reviews in the svc area before re-Proposing the request.
02-10-2023