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

8254598: StringDedupTable should use OopStorage #3662

Closed
wants to merge 10 commits into from

Conversation

@kimbarrett
Copy link

@kimbarrett kimbarrett commented Apr 23, 2021

Please review this change to the String Deduplication facility. It is being
changed to use OopStorage to hold weak references to relevant objects,
rather than bespoke data structures requiring dedicated processing phases by
supporting GCs.

(The Shenandoah update was contributed by Zhengyu Gu.)

This change significantly simplifies the interface between a given GC and
the String Deduplication facility, which should make it much easier for
other GCs to opt in. However, this change does not alter the set of GCs
providing support; currently only G1 and Shenandoah support string
deduplication. Adding support by other GCs will be in followup RFEs.

Reviewing via the diffs might not be all that useful for some parts, as
several files have been essentially completely replaced, and a number of
files have been added or eliminated. The full webrev might be a better
place to look.

The major changes are in gc/shared/stringdedup/* and in the supporting
collectors, but there are also some smaller changes in other places, most
notably classfile/{stringTable,javaClasses}.

This change is additionally labeled for review by core-libs, although there
are no source changes there. This change injects a byte field of bits into
java.lang.String, using one of the previously unused padding bytes in that
class. (There were two unused bytes, now only one.)

Testing:
mach5 tier1-2 with and without -XX:+UseStringDeduplication

Locally (linux-x64) ran all of the existing tests that use string
deduplication with both G1 and Shenandoah. Note that
TestStringDeduplicationInterned.java is disabled for shenandoah, as it
currently fails, for reasons I haven't figured out but suspect are test
related.

  • gc/stringdedup/ -- these used to be in gc/g1
  • runtime/cds/SharedStringsDedup.java
  • runtime/cds/appcds/cacheObject/DifferentHeapSizes.java
  • runtime/cds/appcds/sharedStrings/*

shenandoah-only:

  • gc/shenandoah/jvmti/TestHeapDump.java
  • gc/shenandoah/TestStringDedup.java
  • gc/shenandoah/TestStringDedupStress.java

Performance tested baseline, baseline + stringdedup, new with stringdedup,
finding no significant differences.

/label hotspot
/label core-libs
/contributor @kimbarrett
/contributor @zhengyu123


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

Reviewers

Contributors

  • Kim Barrett <kbarrett@openjdk.org>
  • Zhengyu Gu <zgu@openjdk.org>

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3662

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Apr 23, 2021

👋 Welcome back kbarrett! 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 hotspot label Apr 23, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 23, 2021

@kimbarrett
The hotspot label was successfully added.

@openjdk openjdk bot added the core-libs label Apr 23, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 23, 2021

@kimbarrett
The core-libs label was successfully added.

@openjdk
Copy link

@openjdk openjdk bot commented Apr 23, 2021

@kimbarrett Syntax: /contributor (add|remove) [@user | openjdk-user | Full Name <email@address>]. For example:

  • /contributor add @openjdk-bot
  • /contributor add duke
  • /contributor add J. Duke <duke@openjdk.org>
@openjdk
Copy link

@openjdk openjdk bot commented Apr 23, 2021

@kimbarrett Syntax: /contributor (add|remove) [@user | openjdk-user | Full Name <email@address>]. For example:

  • /contributor add @openjdk-bot
  • /contributor add duke
  • /contributor add J. Duke <duke@openjdk.org>
@kimbarrett
Copy link
Author

@kimbarrett kimbarrett commented Apr 24, 2021

/contributor add @kimbarrett
/contributor add @zhengyu123

@openjdk
Copy link

@openjdk openjdk bot commented Apr 24, 2021

@kimbarrett
Contributor Kim Barrett <kbarrett@openjdk.org> successfully added.

@openjdk
Copy link

@openjdk openjdk bot commented Apr 24, 2021

@kimbarrett
Contributor Zhengyu Gu <zgu@openjdk.org> successfully added.

@kimbarrett kimbarrett force-pushed the kimbarrett:new_dedup2 branch 2 times, most recently from 8a98add to bc96315 Apr 24, 2021
@kimbarrett kimbarrett force-pushed the kimbarrett:new_dedup2 branch from bc96315 to 2df362c Apr 24, 2021
@openjdk openjdk bot added the rfr label Apr 24, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Apr 24, 2021

Webrevs

Copy link

@coleenp coleenp left a comment

I looked at the runtime code, which looks fine. I didn't read the GC code.

@openjdk
Copy link

@openjdk openjdk bot commented Apr 27, 2021

@kimbarrett 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 new_dedup2
git fetch https://git.openjdk.java.net/jdk master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push
Copy link
Contributor

@zhengyu123 zhengyu123 left a comment

Just FYI:
Concurrent GC, such as Sheanndoah and ZGC (if it decides to implement string deduplication in the future), can not enqueue candidates during concurrent thread root scanning, because of potential lock rank inversion between OopStorage lock and stack watermark lock.

src/hotspot/share/classfile/stringTable.cpp Outdated Show resolved Hide resolved
@iklam
iklam approved these changes May 3, 2021
Copy link
Member

@iklam iklam left a comment

The CDS changes look reasonable to me.

Copy link
Contributor

@tschatzl tschatzl left a comment

First pass, just comment suggestions for now.

src/hotspot/share/classfile/javaClasses.hpp Outdated Show resolved Hide resolved
src/hotspot/share/classfile/javaClasses.hpp Outdated Show resolved Hide resolved
src/hotspot/share/classfile/javaClasses.hpp Outdated Show resolved Hide resolved
@kimbarrett
Copy link
Author

@kimbarrett kimbarrett commented May 7, 2021

I've made some improvements to comments, responding to Thomas's suggestions. Ive also changed some of the naming around the injected java.lang.String flags, with modification now using test-and-set semantics (and named accordingly), i.e. returning true if already set rather than if changed.

I've not yet dealt with the merge conflict in Shenandoah, but it looks like it should be fairly easy. Just waiting for more comments before dealing with merging updates.

Copy link
Contributor

@tschatzl tschatzl left a comment

Lgtm.

Copy link
Member

@albertnetymk albertnetymk left a comment

Just some minor comments.

@kimbarrett
Copy link
Author

@kimbarrett kimbarrett commented May 13, 2021

Following up on an off-line discussion with @albertnetymk , I've done a little refactoring of Requests::add. I also made a few other small cleanups, noticed while dealing with @albertnetymk comments. I still haven't dealt with the accumulated merge conflicts. I'll be doing that next.

@openjdk
Copy link

@openjdk openjdk bot commented May 14, 2021

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

8254598: StringDedupTable should use OopStorage

Co-authored-by: Kim Barrett <kbarrett@openjdk.org>
Co-authored-by: Zhengyu Gu <zgu@openjdk.org>
Reviewed-by: coleenp, iklam, tschatzl, ayang

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.

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

@openjdk openjdk bot added ready and removed merge-conflict labels May 14, 2021
@kimbarrett
Copy link
Author

@kimbarrett kimbarrett commented May 14, 2021

The "merge from master" commit (ccb9951) doesn't build with Shenandoah. I've asked Zhengyu to take a look.

Copy link
Contributor

@zhengyu123 zhengyu123 left a comment

The "merge from master" commit (ccb9951) doesn't build with Shenandoah. I've asked Zhengyu to take a look.

Just missing a parameter:

index ddaa66ccc14..93a067fa22d 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahSTWMark.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahSTWMark.cpp
@@ -57,7 +57,7 @@ ShenandoahInitMarkRootsClosure::ShenandoahInitMarkRootsClosure(ShenandoahObjToSc
 
 template <class T>
 void ShenandoahInitMarkRootsClosure::do_oop_work(T* p) {
-  ShenandoahMark::mark_through_ref<T, NO_DEDUP>(p, _queue, _mark_context, false);
+  ShenandoahMark::mark_through_ref<T, NO_DEDUP>(p, _queue, _mark_context, NULL, false);
 }```
size_t _number_of_buckets;
size_t _bucket_index;
size_t _shrink_index;
bool _grow_only;

This comment has been minimized.

@zhengyu123

zhengyu123 May 14, 2021
Contributor

Indentation

This comment has been minimized.

@kimbarrett

kimbarrett May 14, 2021
Author

Not sure what this indentation comment is referring to.

@kimbarrett
Copy link
Author

@kimbarrett kimbarrett commented May 14, 2021

Thanks @zhengyu123 for the shenandoah merge fix.

Thanks @iklam , @coleenp , @tschatzl , @albertnetymk for reviews.

/integrate

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

@openjdk openjdk bot commented May 14, 2021

@kimbarrett Pushed as commit be0a655.

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

@kimbarrett kimbarrett deleted the kimbarrett:new_dedup2 branch May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment