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
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
- duplicates
-
JDK-8322142 JFR: Periodic tasks aren't orphaned between recordings
- Resolved