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

JDK-8287061: Support for rematerializing scalar replaced objects participating in allocation merges #12897

Closed

Conversation

JohnTortugo
Copy link
Contributor

@JohnTortugo JohnTortugo commented Mar 7, 2023

Can I please get reviews for this PR?

The most common and frequent use of NonEscaping Phis merging object allocations is for debugging information. The two graphs below show numbers for Renaissance and DaCapo benchmarks - similar results are obtained for all other applications that I tested.

With what frequency does each IR node type occurs as an allocation merge user? I.e., if the same node type uses a Phi N times the counter is incremented by N:

image

What are the most common users of allocation merges? I.e., if the same node type uses a Phi N times the counter is incremented by 1:

image

This PR adds support scalar replacing allocations participating in merges used as debug information OR as a base for field loads. I plan to create subsequent PRs to enable scalar replacement of merges used by other node types (CmpP is next on the list) subsequently.

The approach I used for rematerialization is pretty straightforward. It consists basically of the following. 1) New IR node (suggested by V. Kozlov), named SafePointScalarMergeNode, to represent a set of SafePointScalarObjectNode; 2) Each scalar replaceable input participating in a merge will get a SafePointScalarObjectNode like if it weren't part of a merge. 3) Add a new Class to support the rematerialization of SR objects that are part of a merge; 4) Patch HotSpot to be able to serialize and deserialize debug information related to allocation merges; 5) Patch C2 to generate unique types for SR objects participating in some allocation merges.

The approach I used for enabling the scalar replacement of some of the inputs of the allocation merge is also pretty straightforward: call MemNode::split_through_phi to, well, split AddP->Load* through the merge which will render the Phi useless.

I tested this with JTREG tests tier 1-4 (Windows, Linux, and Mac) and didn't see regression. I also experimented with several applications and didn't see any failure. I also ran tests with "-ea -esa -Xbatch -Xcomp -XX:+UnlockExperimentalVMOptions -XX:-TieredCompilation -server -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions -XX:+StressLCM -XX:+StressGCM -XX:+StressCCP" and didn't observe any related failures.


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-8287061: Support for rematerializing scalar replaced objects participating in allocation merges (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 12897

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 7, 2023

👋 Welcome back cslucas! 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 Pull request is ready for review label Mar 7, 2023
@openjdk
Copy link

openjdk bot commented Mar 7, 2023

@JohnTortugo The following labels will be automatically applied to this pull request:

  • hotspot
  • security

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

@openjdk openjdk bot added security security-dev@openjdk.org hotspot hotspot-dev@openjdk.org labels Mar 7, 2023
@JohnTortugo
Copy link
Contributor Author

/label add hotspot-runtime

@openjdk openjdk bot added the hotspot-runtime hotspot-runtime-dev@openjdk.org label Mar 7, 2023
@openjdk
Copy link

openjdk bot commented Mar 7, 2023

@JohnTortugo
The hotspot-runtime label was successfully added.

@mlbridge
Copy link

mlbridge bot commented Mar 7, 2023

@merykitty
Copy link
Member

/label hotspot-compiler

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Mar 14, 2023
@openjdk
Copy link

openjdk bot commented Mar 14, 2023

@merykitty
The hotspot-compiler label was successfully added.

@openjdk
Copy link

openjdk bot commented Mar 14, 2023

@JohnTortugo this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout rematerialization-of-merges
git fetch https://git.openjdk.org/jdk master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added merge-conflict Pull request has merge conflict with target branch and removed rfr Pull request is ready for review labels Mar 14, 2023
@openjdk openjdk bot added rfr Pull request is ready for review and removed merge-conflict Pull request has merge conflict with target branch labels Mar 15, 2023
Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Thank you, @JohnTortugo, for continue working on it. I will test it and do proper review late.
Of cause @iwanowww have to approve it too :)

@vnkozlov
Copy link
Contributor

You new test failed in GHA testing with 32-bit VM: Could not find VM flag "UseCompressedOops" in @IR rule 1 at int.
You need to adjust next rule: @IR(counts = { IRNode.ALLOC, "2" }, applyIf = { "UseCompressedOops", "false" })

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

Initial review.

src/hotspot/share/code/debugInfo.hpp Outdated Show resolved Hide resolved
src/hotspot/share/opto/callnode.cpp Outdated Show resolved Hide resolved
src/hotspot/share/opto/callnode.hpp Outdated Show resolved Hide resolved
src/hotspot/share/opto/macro.hpp Outdated Show resolved Hide resolved
src/hotspot/share/opto/callnode.hpp Outdated Show resolved Hide resolved
… & create new IR class to represent scalarized merges.
@iwanowww
Copy link

Overall, the testing went well. (It discovered some minor issues I commented about.)
I'm rerunning some benchmarks which reported suspicious results. Will keep you posted.

@iwanowww
Copy link

iwanowww commented Jun 17, 2023

Testing results (both functional and performance) are good.

In addition, I tested with a guarantee that no retry_no_reduce_allocation_merges() failures are observed and there were no failures observed.

Once you address my latest comments I'll mark the PR as reviewed.

@JohnTortugo
Copy link
Contributor Author

Thank you once more for the comments @iwanowww . I’ll address them asap.

Can I ask what requirements are there for a product flag?

@iwanowww
Copy link

iwanowww commented Jun 20, 2023

Can I ask what requirements are there for a product flag?

Product flags are treated as part of public API of the JVM. So, changes in behavior have to go through CSR process. Also, a product flag has to be deprecated/obsoleted first before it can be removed which takes multiple releases to happen. Better to avoid introducing new product flags unless it is well-justified or necessary.

@JohnTortugo
Copy link
Contributor Author

JohnTortugo commented Jul 6, 2023

@iwanowww - I believe I've addressed all your comments so far. Is everything still looking good?

Copy link

@iwanowww iwanowww left a comment

Choose a reason for hiding this comment

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

The patch looks good.

I resubmitted testing with the latest version and the results are clean.

@openjdk
Copy link

openjdk bot commented Jul 10, 2023

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

8287061: Support for rematerializing scalar replaced objects participating in allocation merges

Reviewed-by: kvn, vlivanov

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

  • aa7367f: 8311921: Inform about MaxExpectedDataSegmentSize in case of pthread_create failures on AIX
  • 753bd56: 8311870: Split CompressedKlassPointers from compressedOops.hpp
  • 0b0e064: 8311656: Shenandoah: Unused ShenandoahSATBAndRemarkThreadsClosure::_claim_token
  • fd7fddb: 8295894: Remove SECOM certificate that is expiring in September 2023
  • d82ade3: 8310683: Refactor StandardCharset/standard.java to use JUnit
  • aac903d: 8311805: Clean up ScrollPane: drop redundant initialiser, mark scroller final
  • 15195e6: 8310066: Improve test coverage for JVMTI GetThreadState on carrier and mounted vthread
  • 6cb9ec3: 6960866: [Fmt-Ch] ChoiceFormat claims impossible and unimplemented functionality
  • 401c3de: 8311645: Memory leak in jspawnhelper spawnChild after JDK-8307990
  • e154b0d: 8311606: Change read_icc_profile() to static function in java.desktop/share/native/libjavajpeg/imageioJPEG.c
  • ... and 29 more: https://git.openjdk.org/jdk/compare/97e99f01d4f317fce1a204c01874a68f5e25a051...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 (@vnkozlov, @iwanowww) 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 Jul 10, 2023
Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

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

The final version looks good to me too.

@JohnTortugo
Copy link
Contributor Author

Thank you all for reviewing this PR! Your feedback made it much better!

@JohnTortugo
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Jul 12, 2023
@openjdk
Copy link

openjdk bot commented Jul 12, 2023

@JohnTortugo
Your change (at version 25b683d) is now ready to be sponsored by a Committer.

@JohnTortugo
Copy link
Contributor Author

@iwanowww @vnkozlov - can I ask one of you to sponsor this PR?

@vnkozlov
Copy link
Contributor

/sponsor

@openjdk
Copy link

openjdk bot commented Jul 17, 2023

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

  • 3236ba0: 8312189: ProblemList serviceability/jvmti/vthread/VThreadTLSTest/VThreadTLSTest.java#id1
  • 5cc71f8: 8312089: Simplify and modernize equals, hashCode, and compareTo in java.nio and implementation code
  • 6a09992: 8311968: Clarify Three-letter time zone IDs in java.util.TimeZone
  • 6ae152d: 8312196: ProblemList test/hotspot/jtreg/applications/ctw/modules/jdk_crypto_ec.java
  • 295ae11: 8312195: Changes in JDK-8284493 use wrong copyright syntax
  • f975be4: 8284493: Improve computeNextExponential tail performance and accuracy
  • e737968: 8308398: Move SunEC crypto provider into java.base
  • 69a46c2: 8310157: Allow void-returning filters for MethodHandles::collectCoordinates
  • 3fb9d11: 8311172: Classfile.PREVIEW_MINOR_VERSION doesn't match that read from class files
  • afcf8e4: 8290005: com/sun/jndi/ldap/LdapCBPropertiesTest.java failling with NullPointerException
  • ... and 84 more: https://git.openjdk.org/jdk/compare/97e99f01d4f317fce1a204c01874a68f5e25a051...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 17, 2023
@openjdk openjdk bot closed this Jul 17, 2023
@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 Jul 17, 2023
@openjdk
Copy link

openjdk bot commented Jul 17, 2023

@vnkozlov @JohnTortugo Pushed as commit a53345a.

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

@ijuma
Copy link

ijuma commented Oct 21, 2023

If I understand correctly, this change was backported to older Microsoft OpenJDK versions. Is there a plan to do the same for upstream?

@JohnTortugo JohnTortugo deleted the rematerialization-of-merges branch April 18, 2024 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org hotspot-compiler hotspot-compiler-dev@openjdk.org hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated security security-dev@openjdk.org
6 participants