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

JFR: jfr print --exact

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 25
    • hotspot
    • None
    • jfr
    • behavioral
    • minimal
    • Hide
      Other options used with 'jfr print' will not be impacted. If '--exact' is used together with '--json' or '--xml', an error message will be printed, similar to when '--json' and '--xml' are both used at the same time.
      Show
      Other options used with 'jfr print' will not be impacted. If '--exact' is used together with '--json' or '--xml', an error message will be printed, similar to when '--json' and '--xml' are both used at the same time.
    • add/remove command in $JDK/bin
    • JDK

      Summary

      Add the command-line switch --exact to the jfr print command.

      Problem

      The jfr print command allows users to print events from a .jfr file in a human-readable format, for example:

      $ jfr print recording.jfr
      
      jdk.FileRead {
        startTime = 16:36:14.373 (2025-04-09)
        duration = 2.02 ms
        path = "/var/folders/g0/cdrkqsy90rz1zq_1c8_xcv4h0000gn/T/+~JF223373.tmp"
        bytesRead = 5.2 MB
        endOfFile = false
        eventThread = "AWT-EventQueue-0" (javaThreadId = 32)
        ...
      }

      This is usually sufficient to see what is happening, but for verification purposes or correlation with other sources, such as perf output or log files, the exact value is sometimes required. One way to view the exact value is to pass --json to jfr print, which displays the recording in a machine-readable format.

      However, this approach makes the output extremely verbose and cumbersome to read. There is a need to display exact values when pretty-printing a recording.

      Solution

      Add the command-line switch --exact so that jfr print outputs timestamps, time spans, percentages, and byte values with full precision, for example:

      $ jfr print --exact recording.jfr
      
      jdk.FileRead {
        startTime = 16:36:14.373600833 (2025-04-09)
        duration = 0.0020170800 s
        path = "/var/folders/g0/cdrkqsy90rz1zq_1c8_xcv4h0000gn/T/+~JF223373.tmp"
        bytesRead = 5458957 bytes
        endOfFile = false
        eventThread = "AWT-EventQueue-0" (javaThreadId = 32)
        ...
      }

      Specification

      src/jdk.jfr/share/classes/jdk/jfr/internal/tool/Print.java

           public List<String> getOptionSyntax() {
               List<String> list = new ArrayList<>();
      -        list.add("[--xml|--json]");
      +        list.add("[--xml|--json|--exact]");
               list.add("[--categories <filter>]");
               list.add("[--events <filter>]");
               list.add("[--stack-depth <depth>]");
      @@ -73,6 +73,8 @@ public void displayOptionUsage(PrintStream stream) {
               stream.println();
               stream.println("  --json                  Print recording in JSON format");
               stream.println();
      +        stream.println("  --exact                 Pretty-print numbers and timestamps with full precision.");
      +        stream.println();
               stream.println("  --categories <filter>   Select events matching a category name.");

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

              Created:
              Updated:
              Resolved: