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

JFR stops recording CPULoad events after making a recording

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 21.0.2
    • hotspot
    • jfr
    • x86_64
    • linux

      ADDITIONAL SYSTEM INFORMATION :
      I observed the issue both on a custom x86 Linux environment as well as on a M1 Mac. I tested 21.0.2 and 22, and observed the same behavior in both versions.

      A DESCRIPTION OF THE PROBLEM :
      I observed that JFR only records CPULoad events on the first recording that's made, and the events are not present on subsequent recordings _unless_ the sample period is changed, in which case they will be present as expected.

      I enabled JFR trace logging and the only difference I noticed between a recording that worked and one that didn't was that only the recording that worked logged lines like the following:

      ```
      [2024-04-12T12:39:51.589-0500][trace] Run periodic event jdk.CPULoad(107) 1000/1000
      ```

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      The following steps should be executed against the same JVM process.

      # Start a recording on a fresh JVM -- this will work
      jcmd $PID JFR.start name=X
      # Wait any amount of time and stop the recording
      jcmd $PID JFR.stop name=X filename=/var/tmp/recording.jfr
      # See that CPULoad events were recorded
      jfr view CPULoad /var/tmp/recording.jfr

      # Now, do the exact same thing again -- this won't work
      jcmd $PID JFR.start name=X
      jcmd $PID JFR.stop name=X filename=/var/tmp/recording.jfr
      # See that **NO** CPULoad events were recorded
      jfr view CPULoad /var/tmp/recording.jfr

      # Change the sample period -- this will work
      jcmd $PID JFR.start name=X jdk.CPULoad#period=1001ms
      jcmd $PID JFR.stop name=X filename=/var/tmp/recording.jfr
      # See that CPULoad events were recorded
      jfr view CPULoad /var/tmp/recording.jfr

      At this point, if you start a new recording with the period set to 1001ms there will be no events again, but changing it back to 1000ms, or any other value, will result in events as expected.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      I expected the CPULoad events would be included in every recording without needing to change the sample period every time.
      ACTUAL -
      CPULoad events are not recorded unless the sample period has changed since the previous recording.

      CUSTOMER SUBMITTED WORKAROUND :
      Changing the sample period so that it is even a millisecond different from the previous recording is sufficient to collect the events, though obviously not ideal.

      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: