RFR: 8284686: Interval of < 1 ms disables ExecutionSample events
Jaroslav Bachorik
jbachorik at openjdk.java.net
Wed Apr 13 09:04:27 UTC 2022
On Mon, 11 Apr 2022 16:53:08 GMT, Johannes Bechberger <duke at openjdk.java.net> wrote:
> Fixes the issue by rounding the period interval to the next full millisecond larger than zero.
>
> The following from the bug report works now:
>
> java -XX:StartFlightRecording=filename=flight.jfr,jdk.ExecutionSample#period=999us CLASS_FILE; jfr print --events jdk.ExecutionSample flight.jfr
>
> It considers the period to be `1ms`, producing the recording as expected.
src/jdk.jfr/share/classes/jdk/jfr/internal/settings/PeriodSetting.java line 118:
> 116: long nanos = Utils.parseTimespanWithInfinity(value);
> 117: if (nanos != Long.MAX_VALUE) {
> 118: eventType.setPeriod(Math.max(1, Math.round(nanos / 1_000_000f)), false, false);
Is `Math.round()` necessary here?
We can just keep the integer division which will result to `0` for all arguments < 1_000_000 and the `Math.max()` will take care of providing the correct default.
Another thing to consider - what should happen if the `nanos` value is indeed `0`. Should the event perhaps be disabled?
-------------
PR: https://git.openjdk.java.net/jdk/pull/8183
More information about the hotspot-jfr-dev
mailing list