JDK-8203930 : Limit amount of data for JFR.dump
  • Type: CSR
  • Component: hotspot
  • Sub-Component: jfr
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 11
  • Submitted: 2018-05-29
  • Updated: 2018-06-21
  • Resolved: 2018-06-08
Related Reports
CSR :  
Description
Summary
-------

Add four parameters to the diagnostic command JFR.dump to simplify usage and limit the amount of data being copied to a file.

Problem
-------
JFR data is written to a disk repository and the way to extract the data is to use a diagnostic command, for example:

    $ jcmd MyApp.jar JFR.dump name=5 filename=file.jfr

The file can then be opened in a tool like JMC. 

The JFR.dump command is cumbersome to use since you need to know the name of the recording you want to dump. The way to find the name is to use the JFR.check command, or remember the name from when the recording was started. Most of the time this step is unnecessary, since there will only be one recording running, and even if multiple recordings are running, the dump file will contain data from all the running recordings due to how JFR is implemented. 

Furthermore, performance or cloud infrastructure that monitors JVMs want to impose as little overhead as possible and the way JFR.dump works today, all the data, possibly GBs, is written to a file, even if only the period when the problem occurred is of interest. This limitation has led to workarounds where users copy data from the disk repository using bash scripts, which is error prone and hard to support.

Solution
--------
The proposal is to remove the need to specify a name. If the name is omitted, data from all recordings are dumped.  If a filename is not specified, a filename will be generated from the PID and the current date. 

This will make JFR easy to use, for example:

    $ jcmd MyApp.jar JFR.start
    $ jcmd MyApp.jar JFR.dump

The proposal is to add the options maxage and maxsize that can restrict the amount of data to dump, for example:

    $ jcmd MyApp.jar JFR.dump maxsize=10MB
    $ jcmd MyApp.jar JFR.dump maxage=60s

To extract data from a particular time, there will also be the options begin and end to specify the interval at which data should be dumped.

    $ jcmd <pid> JFR.dump begin=15:00 
    $ jcmd <pid> JFR.dump end=17:00 maxsize=100MB
    $ jcmd <pid> JFR.dump begin=12:00:00 end=13:00:00

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

JFR.dump 

    NANOTIME maxage 
    LONG maxsize
    STRING begin
    STRING end

The begin and end time will be parsed using Instant, LocalTime, and LocalDateTime. If no data exists in the specified interval, for instance if begin happens after end, a message will be written explaining that there is no data in the interval. Negative values for maxsize and maxage will not be accepted. If the filename is omitted, the name will be generated using Paths.get(".", "hotspot" + pid + ["-" + recordingId +] "-" + DateTimeFormatter.ofPattern("yyyy_MM_dd_HH_mm_ss").format(LocalDateTime.now()), where "." will resolve to the directory where the JVM process was started. This is similar to JFR.start without an explicit filename.
Comments
Moving to Approved.
08-06-2018

What happens if BEGIN is after END? Presumably no events. Please add more information about where and how the implicit temporary file is created if an explicit file is not specified. Moving the request to Pended; please re-finalize afterward.
08-06-2018