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

8317349: Randomize order of macro node expansion in C2 #17684

Closed
wants to merge 5 commits into from

Conversation

dlunde
Copy link
Member

@dlunde dlunde commented Feb 2, 2024

This changeset adds a flag StressMacroExpansion which randomizes macro expansion ordering for stress testing purposes.

Changes:

  • Implement the flag StressMacroExpansion.
  • Add functionality tests for StressMacroExpansion, analogous to testing for previous stress flags such as StressIGVN.
  • Add StressMacroExpansion to a number of tests that already turn on all other stress flags (and therefore should also use StressMacroExpansion).
  • Rename the previous compiler phase MACRO_EXPANSION to AFTER_MACRO_EXPANSION.
  • Add a new Ideal phase for individual macro expansion steps, allowing StressMacroExpansion testing. Below is a sample phase list screenshot including the new phase (IGV print level 5 with "After Iter GVN Step" omitted).

Question for the review: are the new macro expansion Ideal phases OK, or should we change anything?

Testing:

  • GitHub Actions
  • tier1 to tier5 on windows-x64, linux-x64, linux-aarch64, macosx-x64, and macosx-aarch64.
  • Tested that thousands of graphs are correctly opened and visualized with IGV.

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8317349: Randomize order of macro node expansion in C2 (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 17684

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17684.diff

Webrev

Link to Webrev Comment

Sorry, something went wrong.

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 2, 2024

👋 Welcome back dlunden! 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 changed the title 8317349 8317349: Randomize order of macro node expansion in C2 Feb 2, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Feb 2, 2024
@openjdk
Copy link

openjdk bot commented Feb 2, 2024

@dlunde The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Feb 2, 2024
@mlbridge
Copy link

mlbridge bot commented Feb 2, 2024

Webrevs

Copy link
Member

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

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

That's a nice stress option! I have a few comments.

@@ -2511,6 +2514,7 @@ bool PhaseMacroExpand::expand_macro_nodes() {
}
assert(!success || (C->macro_count() == (old_macro_count - 1)), "elimination must have deleted one node from macro list");
progress = progress || success;
if (success) { C->print_method(PHASE_AFTER_MACRO_EXPANSION_ELIMINATE, 4, n); }
Copy link
Member

Choose a reason for hiding this comment

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

I suggest to put it on a new line.

Suggested change
if (success) { C->print_method(PHASE_AFTER_MACRO_EXPANSION_ELIMINATE, 4, n); }
if (success) {
C->print_method(PHASE_AFTER_MACRO_EXPANSION_ELIMINATE, 4, n);
}

I think dumping at level 4 (same for the other newly added dumps) is too verbose already but when dumping at level 5, you have the overhead of additional IGVN step dumps. I could imagine that you either want macro expansion dumps OR IGVN step dumps but not always both. So, it looks like we've now reached a point where it would have been nice to enable/disable certain dumps.

Anyway, since this is not possible I suggest to move these dumps to level 5 for now. But I'm open for other opinions about that.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should also add this to eliminate_macro_nodes() when eliminating locks, allocations, and boxing nodes. But then again, we also dump the graphs directly after EA since eliminate_macro_nodes() is also called from there. Not sure if that's wanted. I guess it's okay being at IGV dump level 5. But we could also restrict the dumps to the post loop opts phase.

Copy link
Contributor

@robcasloz robcasloz left a comment

Choose a reason for hiding this comment

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

Looks good to me, modulo Christian's comments. Regarding whether to randomize macro node elimination, I find it a bit confusing that PhaseMacroExpand also eliminates macro nodes, perhaps it would be better to, in a separate RFE, split the phase into PhaseMacroEliminate and PhaseMacroExpand, and introduce a separate StressMacroElimination option and new phase names for the former?

@dlunde
Copy link
Member Author

dlunde commented Feb 5, 2024

Thanks @chhagedorn and @robcasloz. I made the trivial changes suggested by Christian, so the remaining question is how to handle dump levels and what/when to dump.

My suggestion: set dump levels to 5 for now, as Christian suggests, but do not yet add any dumps to eliminate_macro_nodes. I'll create a separate RFE with Roberto's suggestion (which I think sounds good and, looking at the code, quite easy to achieve through a bit of restructuring) together with IGV dumping for macro elimination. What do you think?

Copy link
Member

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

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

Thanks for the updates!

Regarding whether to randomize macro node elimination, I find it a bit confusing that PhaseMacroExpand also eliminates macro nodes, perhaps it would be better to, in a separate RFE, split the phase into PhaseMacroEliminate and PhaseMacroExpand, and introduce a separate StressMacroElimination option and new phase names for the former?

I agree with that. A new phase would be better. Let's do that in a separate RFE.

My suggestion: set dump levels to 5 for now, as Christian suggests, but do not yet add any dumps to eliminate_macro_nodes. I'll create a separate RFE with Roberto's suggestion (which I think sounds good and, looking at the code, quite easy to achieve through a bit of restructuring) together with IGV dumping for macro elimination. What do you think?

Sounds good!

@openjdk
Copy link

openjdk bot commented Feb 6, 2024

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

8317349: Randomize order of macro node expansion in C2

Reviewed-by: chagedorn, rcastanedalo, thartmann

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

  • 3bffe22: 8319463: ClassSignature should have superclass and superinterfaces as ClassTypeSig
  • e0d98dd: 8325257: jshell reports NoSuchFieldError with instanceof primitive type
  • f2f6344: 8325347: Rename native_thread.h
  • 1797efd: 8322218: Better escaping of single and double quotes in annotation toString() results
  • 0f5f3c9: 8325254: CKA_TOKEN private and secret keys are not necessarily sensitive
  • 4b1e367: 8325152: Clarify specification of java.io.RandomAccessFile.setLength
  • 96eb039: 8324665: Loose matching of space separators in the lenient date/time parsing mode
  • 2d252ee: 8325180: Rename jvmti_FollowRefObjects.h
  • b814c31: 8321703: jdeps generates illegal dot file containing nodesep=0,500000
  • 50b17d9: 8316704: Regex-free parsing of Formatter and FormatProcessor specifiers
  • ... and 135 more: https://git.openjdk.org/jdk/compare/6d36eb78ad781ecd80d66d1319921a8746820394...master

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.

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 (@chhagedorn, @robcasloz, @TobiHartmann) 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 ready Pull request is ready to be integrated label Feb 6, 2024
Copy link
Contributor

@robcasloz robcasloz left a comment

Choose a reason for hiding this comment

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

Looks good!

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

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

Nice! The changes look good to me.

@vnkozlov
Copy link
Contributor

vnkozlov commented Feb 6, 2024

Looks good to me, modulo Christian's comments. Regarding whether to randomize macro node elimination, I find it a bit confusing that PhaseMacroExpand also eliminates macro nodes, perhaps it would be better to, in a separate RFE, split the phase into PhaseMacroEliminate and PhaseMacroExpand, and introduce a separate StressMacroElimination option and new phase names for the former?

Yes, I agree with this.

@dlunde
Copy link
Member Author

dlunde commented Feb 7, 2024

I've now rerun tests and this is ready for integration. Thanks for the reviews, please sponsor!

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Feb 7, 2024
@openjdk
Copy link

openjdk bot commented Feb 7, 2024

@dlunde
Your change (at version 660cc89) is now ready to be sponsored by a Committer.

@robcasloz
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented Feb 7, 2024

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

  • 3bffe22: 8319463: ClassSignature should have superclass and superinterfaces as ClassTypeSig
  • e0d98dd: 8325257: jshell reports NoSuchFieldError with instanceof primitive type
  • f2f6344: 8325347: Rename native_thread.h
  • 1797efd: 8322218: Better escaping of single and double quotes in annotation toString() results
  • 0f5f3c9: 8325254: CKA_TOKEN private and secret keys are not necessarily sensitive
  • 4b1e367: 8325152: Clarify specification of java.io.RandomAccessFile.setLength
  • 96eb039: 8324665: Loose matching of space separators in the lenient date/time parsing mode
  • 2d252ee: 8325180: Rename jvmti_FollowRefObjects.h
  • b814c31: 8321703: jdeps generates illegal dot file containing nodesep=0,500000
  • 50b17d9: 8316704: Regex-free parsing of Formatter and FormatProcessor specifiers
  • ... and 135 more: https://git.openjdk.org/jdk/compare/6d36eb78ad781ecd80d66d1319921a8746820394...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Feb 7, 2024
@openjdk openjdk bot closed this Feb 7, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Feb 7, 2024
@openjdk
Copy link

openjdk bot commented Feb 7, 2024

@robcasloz @dlunde Pushed as commit 4abb10e.

💡 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
Labels
hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

None yet

5 participants