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

Implement JEP 520: JFR Method Timing and Tracing

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P2 P2
    • 25
    • hotspot
    • None
    • jfr
    • source
    • minimal
    • add/remove/modify command line option
    • JDK

      Summary

      JEP 520 Method &Timing introduces two new events jdk.MethodTrace and jdk.MethodTiming with a new event setting called "filter" to the specification of the jdk.jfr package. Also, two new option aliases method-trace and method-timing for the events are introduced to the configuration files default.jfc and profile.jfc.

      Problem

      JEP 520 Method &Timing tracing allows configuration of two new events, jdk.MethodTrace and jdk.MethodTiming, but it's a bit cumbersome and unintuitive to use them directly, for example, jdk.MethodTrace#filter=java.lang.String For more information about motivation, see JEP.

      Solution

      Introduce the option aliases method-trace and method-timing, so users can more easily time and trace methods from the shell, for example:

      $ java -XX:StartFlightRecording:method-trace=java.util.HashMap::resize ...
      $ java -XX:StartFlightRecording:method-timing=::<clinit> ...
      $ jcmd <pid> JFR.start method-timing=@jakarta.ws.rs.GET 

      The output for -XX:StartFlightRecording:help points to the documentation for jdk.jfr package, so it is also updated with the new event setting "filter" and the grammar for it. For more information, see Description of JEP.

      Specification

      default.jfc

      +       <text name="method-timing" label="Method Timing" contentType="text"></text>
      + 
      +       <text name="method-trace" label="Method Trace" contentType="text"></text>
      + 

      profile.jfc

      +       <text name="method-timing" label="Method Timing" contentType="text"></text>
      + 
      +       <text name="method-trace" label="Method Trace" contentType="text"></text>
      + 

      jdk/jfr/package-info.java

      + * <tr>
      + * <th scope="row">{@code filter}</th>
      + * <td>Specifies the filter for the event</td>
      + * <td>{@code ""} (empty string)</td>
      + * <td>An empty string if no filter is used. Otherwise, a
      + * filter that can be used with the jdk.MethodTrace or
      + * jdk.MethodTiming events and follows this grammar:<br>
      + * {@snippet :
      + * filter ::= target (";" target)*
      + * target ::= class | class-method | method | annotation
      + * class ::= identifier ("." identifier)*
      + * class-method ::= class method
      + * method ::= "::" method-name
      + * method-name ::= identifier | "<clinit>" | "<init>"
      + * annotation ::= "@" class
      + * identifier ::= see JLS 3.8
      + * }
      + * </td>
      + * <td>{@code "java.lang.String"}<br>
      + * {@code "::<clinit>"}<br>
      + * {@code "java.util.HashMap::resize"}<br>
      + * {@code "java.io.FileDescriptor::<init>;java.io.FileDescriptor::close"}<br>
      + * {@code  "@jakarta.ws.rs.GET"}<br>
      + * </td>
      + * </tr>

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

              Created:
              Updated:
              Resolved: