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

JFR: Periodic task thread spins after recording has stopped

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 21
    • 17, 21
    • hotspot
    • None
    • jfr
    • b12

      Running the following program:

      import jdk.jfr.Recording;
      import jdk.jfr.Configuration;
      public class P {
        public static void main(String... args) throws Exception {
          Configuration c = Configuration.getConfiguration("default");
          try (Recording r = new Recording(c)) {
             r.start();
             Thread.sleep(10_000);
          }
          System.out.println("Recording finished");
          Thread.sleep(1000_000);
        }
      }

      With the following line added to RequestEngine.java:

           private static long run_requests(Collection<RequestHook> entries, long eventTimestamp) {
               long last = lastTimeMillis;
      + System.out.println("Time: " + last);
               // The interval for periodic events is typically at least 1 s, so
               // System.currentTimeMillis() is sufficient. JVM.counterTime() lacks

      results in:

      Time: 1676829368686
      Time: 1676829368699
      Time: 1676829368711
      Time: 1676829368722
      Time: 1676829368735
      Time: 1676829368747
      Time: 1676829368760
      Time: 1676829368773
      ...

      The "JFR Periodic Task" thread runs back-to-back, with about 13 ms between each each turn. One would expect the thread to be stopped or at least sleep/wait when a recording is finished. Furthermore, flush calls are made into JVM.after native JFR has been destroyed.

      I think this can explain som strange things we have seen, crashes or timeouts.

            egahlin Erik Gahlin
            egahlin Erik Gahlin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: