Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7231: JMC createReport for JMC8 Automated Analysis fails to evaluate several rules #311

Closed
wants to merge 6 commits into from

Conversation

aptmac
Copy link
Member

@aptmac aptmac commented Sep 24, 2021

This PR addresses JMC-7231 [0], in which using JfrHtmlRulesReport throws a number of exceptions and fails to evaluate a handful of rules.

I used some of the review comments [1] that I made in the other open PR to address the same issue.

As far as I can tell, there are two main issues here.

The first is some rules now (after the Rules 2.0 update) have dependencies, these are (4) GcLockerRule, GcStallRule, HeapInspectionRule, and SystemGcRule which depend on GarbageCollectionInfoRule. The problem here is that if GarbageCollectionInfoRule isn't evaluated then the other four rules end up throwing an NPE while trying to evaluate.

The second issue is that as of Rules 2.0, on the jmc.ui Automated Analysis page we use RulesToolkit.matchesEventAvailabilityMap() to verify is an event is is available and if the rule should be evaluated. This check wasn't replicated on the core implementation, so I've added it in. What's interesting here is that in the test jfr I was using, GarbageCollectionInfoRule was filtered out by matchesEventAvailabilityMap(), which was causing the above 4 Gc rules to explode.

The solution I've put together uses two lists to track 1). rules that are unavailable due to being filtered out by matchesEventAvailabilityMap(), and 2). rules that have dependencies. It later loops through the list of rules with dependencies, and checks to see if they exist in the list with unavailable rules. If a rule is not able to be evaluated by either 1). not being available or 2). by having a dependency that is not available, it returns a completed future IResult containing "not available", similar to how on this is handled on the jmc.ui side. Then the rest of the rules report proceeds as usual.

I think the easiest way to verify/try this fix is by creating a run configuration for JfrHtmlRulesReport in Eclipse, and feeding it a jfr file.

[0] https://bugs.openjdk.java.net/browse/JMC-7231
[1] #302 (review)


Progress

  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JMC-7231: JMC createReport for JMC8 Automated Analysis fails to evaluate several rules

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jmc pull/311/head:pull/311
$ git checkout pull/311

Update a local copy of the PR:
$ git checkout pull/311
$ git pull https://git.openjdk.java.net/jmc pull/311/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 311

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jmc/pull/311.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Sep 24, 2021

👋 Welcome back aptmac! 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 openjdk bot added the rfr label Sep 24, 2021
@mlbridge
Copy link

mlbridge bot commented Sep 24, 2021

Webrevs

Copy link
Member

@thegreystone thegreystone left a comment

Choose a reason for hiding this comment

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

LGTM, but I'd prefer @Gunde to review this.

@thegreystone
Copy link
Member

It could be worth getting this particular fix into an 8.1.1 release.

@thegreystone
Copy link
Member

/reviewers 2

@openjdk
Copy link

openjdk bot commented Oct 4, 2021

@thegreystone
The number of required reviews for this PR is now set to 2 (with at least 1 of role committers).

* provider of configuration values used by the ResultBuilder
* @return a completed future containing an evaluation error result
*/
private static Future<IResult> evaluationErrorResult(IRule rule, IPreferenceValueProvider preferences) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it might be slightly confusing that this is labeled with "error" if the rule evaluation did not fail, just did not take place. It could probably just be a N/A result instead, which we should already have methods for in RulesToolkit.

Comment on lines 1237 to 1244
boolean shouldEvaluate = true;
for (IRule unavailableRule : unavailableRules) {
if (dependencyName.equals(unavailableRule.getId())) {
shouldEvaluate = false;
resultFutures.put(rule, evaluationErrorResult(rule, preferences));
break;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not enough to determine whether or not a rule should be evaluated. The @dependsOn annotation specifies both a class and an optional minimum severity that the prior rule must return for the current rule to evaluate. If we disregard this we risk running into NPEs for later rules as they attempt to access results that might not be present in the RulesProvider.

Copy link
Member Author

Choose a reason for hiding this comment

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

Right, thanks for pointing that out. I'll put a severity check into there similar to how it's done in RuleManager: https://github.com/openjdk/jmc/blob/master/application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/RuleManager.java#L114

@aptmac
Copy link
Member Author

aptmac commented Oct 6, 2021

I've incorporated Henrik's review comments into this latest commit.

The first addressed change is making use of RulesToolkit.getNotApplicableResult() for rules that are not evaluated. I tried to make it such that the messages associated with these NA results match what is used in RuleManager.

The second addressed change is to take the dependency's result severity value into account when evaluating a rule. On the UI side, this is done by RuleManager.shouldEvaluate(), so I've created a similar function at RulesToolkit.shouldEvaluate(), that takes a rule and the result of its dependency rule.

Lastly I tried to reorganize the code a bit so it should be easier to keep track of the rules (with dependencies), their dependencies, and the computed result of these dependencies.

@thegreystone thegreystone self-requested a review October 6, 2021 16:27
@openjdk
Copy link

openjdk bot commented Oct 14, 2021

@aptmac 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:

7231: JMC createReport for JMC8 Automated Analysis fails to evaluate several rules

Reviewed-by: hirt, hdafgard

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 2 new commits pushed to the master branch:

  • 90197d6: 7419: Update XML parsing
  • 3424e72: 7409: Update the spotless maven plugin

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready label Oct 14, 2021
@aptmac
Copy link
Member Author

aptmac commented Oct 14, 2021

/integrate

@openjdk
Copy link

openjdk bot commented Oct 14, 2021

Going to push as commit c725078.
Since your change was applied there have been 2 commits pushed to the master branch:

  • 90197d6: 7419: Update XML parsing
  • 3424e72: 7409: Update the spotless maven plugin

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Oct 14, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Oct 14, 2021
@openjdk
Copy link

openjdk bot commented Oct 14, 2021

@aptmac Pushed as commit c725078.

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

@aptmac aptmac deleted the 7231 branch October 14, 2021 15:05
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.

3 participants