RFR: JDK-8263426: Reflow JfrNetworkUtilization::send_events
Aleksey Shipilev
shade at openjdk.java.net
Thu Mar 11 09:38:24 UTC 2021
SonarCloud instance reports a problem in JfrNetworkUtilization::send_events: "Identical sub-expressions on both sides of operator "-"." here:
const JfrTickspan interval = last_sample_instant == 0 ? cur_time - cur_time : cur_time - last_sample_instant;
Note `cur_time - cur_time`. It would seem that `interval` is effectively zero when `last_sample_instant` is not yet initialized. And I see that the subsequent code checks for `interval.value() > 0` for every interface. That can be optimized a bit: when `last_sample_instant` is not available, do not enter the loop, and don't check `interval.value()`.
Additional testing:
- [x] `jdk_jfr` on Linux x86_64
-------------
Commit messages:
- JDK-8263426: Reflow JfrNetworkUtilization::send_events
Changes: https://git.openjdk.java.net/jdk/pull/2935/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=2935&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8263426
Stats: 6 lines in 1 file changed: 1 ins; 1 del; 4 mod
Patch: https://git.openjdk.java.net/jdk/pull/2935.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/2935/head:pull/2935
PR: https://git.openjdk.java.net/jdk/pull/2935
More information about the hotspot-jfr-dev
mailing list