Skip to content

Conversation

aymane-harmaz
Copy link
Member

@aymane-harmaz aymane-harmaz commented Sep 23, 2025

When plotting event count histogram and all event durations are set to 0, the duration range will be evaluated to 0, leading to an ArithmeticException (divid by 0), which stops JMC from plotting that histogram.

This can be shown on the attached screenshot, where only the percentile table is shown and the histogram chart is missing

missing-histogram

Progress

  • Commit message must refer to an issue
  • Change must be properly reviewed (1 review required, with at least 1 Committer)

Issue

  • JMC-8439: ArithmeticException thrown when plotting event count histogram with maxDuration set to 0 (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jmc.git pull/675/head:pull/675
$ git checkout pull/675

Update a local copy of the PR:
$ git checkout pull/675
$ git pull https://git.openjdk.org/jmc.git pull/675/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 675

View PR using the GUI difftool:
$ git pr show -t 675

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jmc/pull/675.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 23, 2025

👋 Welcome back aymane-harmaz! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Sep 23, 2025

@aymane-harmaz This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8439: ArithmeticException thrown when plotting event count histogram with maxDuration set to 0

Reviewed-by: hirt

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@thegreystone) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the rfr label Sep 23, 2025
@mlbridge
Copy link

mlbridge bot commented Sep 23, 2025

Webrevs

@thegreystone thegreystone self-requested a review September 25, 2025 15:06
// Get the maximum duration to set chart bounds
IQuantity maxDuration = itemsWithDuration.getAggregate(JdkAggregators.LONGEST_EVENT);
if (maxDuration == null) {
if (maxDuration == null || maxDuration.doubleValueIn(UnitLookup.MILLISECOND) == 0.0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. To avoid FP equality and unit conversion surprises, please compare against zero using nanoseconds:
maxDuration.longValueIn(UnitLookup.NANOSECOND) == 0L

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the insight.
I used clampedLongValueIn as the only critical case here is equality with 0L, and this way we don’t need to handle conversion exceptions explicitly

@thegreystone
Copy link
Member

Good to go!

@openjdk openjdk bot added the ready label Sep 27, 2025
@aymane-harmaz
Copy link
Member Author

Thanks for the review.

/integrate

@openjdk openjdk bot added the sponsor label Sep 27, 2025
@openjdk
Copy link

openjdk bot commented Sep 27, 2025

@aymane-harmaz
Your change (at version 9e8221a) is now ready to be sponsored by a Committer.

@thegreystone
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Oct 8, 2025

Going to push as commit 58ca84a.

@openjdk openjdk bot added the integrated label Oct 8, 2025
@openjdk openjdk bot closed this Oct 8, 2025
@openjdk
Copy link

openjdk bot commented Oct 8, 2025

@thegreystone @aymane-harmaz Pushed as commit 58ca84a.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants