Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8351370

JFR: -XX:StartFlightRecording:report-on-exit

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 25
    • hotspot
    • None
    • jfr
    • behavioral
    • minimal
    • A new option is added to -XX:StartFlightRecording, but it will not change how the existing options work.
    • add/remove/modify command line option
    • JDK

      Summary

      Add the option 'report-on-exit' to -XX:StartFlightRecording so that summary reports, aka 'jfr views', are written when the JVM exits.

      Problem

      To get a summary view from the 'jfr' tool, users must first specify a filename with -XX:StartFlightRecording to dump a recording file to disk when the JVM exits. Next, they must run the 'jfr' tool against that recording file to display a summary, such as the hot-methods view. Finally, they must delete the file unless they want to keep it for other things.

      Example workflow:

      $ java -XX:StartFlightRecording:filename=dump.jfr ...
      $ jfr view hot-methods
      $ rm dump.jfr

      This process is unnecessarily cumbersome.

      Solution

      Allow users to specify the name of the 'jfr view' directly with -XX:StartFlightRecording to have it printed automatically when the JVM exits. It eliminates the need to specify a filename, run a separate tool, and delete the file afterward.

      Example workflow:

      $ java -XX:StartFlightRecording:report-on-exit=hot-methods ...

      If JFR records data to memory (which occurs when disk=false is specified), generating the report is impossible unless the data is first copied to disk. Although it is technically possible to implement a mechanism to copy the data from memory to disk before generating the report, this would override the user's explicit choice, so -XX:StartFlightRecording will not accept report-on-exit in combination with disk=false. Instead, the JVM will fail to start and print an error message.

      Specification

      diff --git a/src/java.base/share/man/java.md b/src/java.base/share/man/java.md
      index 32280f2c516..987dbf64159 100644
      --- a/src/java.base/share/man/java.md
      +++ b/src/java.base/share/man/java.md
      @@ -1447,6 +1447,12 @@ ## Advanced Runtime Options for Java
               the potential leaking object was allocated is included in the
               information collected.
      
      +    `report-on-exit=`*identifier*
      +    :   Specifies the name of the view to display when the Java Virtual Machine
      +        (JVM) shuts down. This option is not available if the disk option is set
      +        to false. For a list of available views, see `jfr help view`. By default,
      +        no report is generated.
      +
           `settings=`*path*
           :   Specifies the path and name of the event settings file (of type JFC).
               By default, the `default.jfc` file is used, which is located in

      e

            egahlin Erik Gahlin
            egahlin Erik Gahlin
            Markus Grönlund
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: