-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
8267185: Add string deduplication support to ParallelGC #5085
8267185: Add string deduplication support to ParallelGC #5085
Conversation
👋 Welcome back iwalulya! A progress list of the required criteria for merging this PR into |
Webrevs
|
@@ -139,6 +139,9 @@ class ParallelScavengeHeap : public CollectedHeap { | |||
// Returns JNI_OK on success | |||
virtual jint initialize(); | |||
|
|||
void safepoint_synchronize_begin(); | |||
void safepoint_synchronize_end(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see no callers of these new functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, never mind. These are overriding virtual function declarations. Please add virtual
. The modern style would be to use override
, but gcc warns if some but not all of a class's overridden virtual functions use override
, and you probably don't want to do that update for this class as part of this change.
@@ -284,6 +285,12 @@ inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o, | |||
} else { | |||
// we'll just push its contents | |||
push_contents(new_obj); | |||
|
|||
if (psStringDedup::is_candidate_from_evacuation(o->klass(), new_obj->age(), new_obj_is_tenured)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think is_candidate_from_evacuation
should just take new_obj
and new_obj_is_tenured
as arguments, and get the klass and age there-in as needed. Maybe there's enough inlining and such that the compiler can optimize away unneeded accesses, but why not make the compiler's and the reader's job easier?
static bool is_candidate_from_evacuation(const Klass* klass, | ||
uint age, | ||
bool obj_is_tenured) { | ||
return StringDedup::is_enabled_string(klass) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better here to first check StringDedup::is_enabled
and only get the klass if it's actually needed. G1 uses StringDedup::is_enabled_string because it happens to already have the klass in hand. That's not the case here; but the caller is getting the klass just for calling this function.
@@ -284,6 +285,12 @@ inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o, | |||
} else { | |||
// we'll just push its contents | |||
push_contents(new_obj); | |||
|
|||
if (psStringDedup::is_candidate_from_evacuation(o->klass(), new_obj->age(), new_obj_is_tenured)) { | |||
if (!java_lang_String::test_and_set_deduplication_requested(o)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting the flag on the from-object isn't useful; it needs to be on the to-object. But I don't think this is needed anyway. is_candidate_from_evacuation
shouldn't generate duplicate requests.
@@ -116,7 +116,7 @@ size_t StringDedup::Config::desired_table_size(size_t entry_count) { | |||
bool StringDedup::Config::ergo_initialize() { | |||
if (!UseStringDeduplication) { | |||
return true; | |||
} else if (!UseG1GC && !UseShenandoahGC && !UseZGC) { | |||
} else if (UseEpsilonGC || UseSerialGC) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is a small land mine for the next new GC project. I'd prefer adding !UseParallelGC. Or rewrite to have an else if (UseXXXGC || ...) { ... } else { // not supported }
structure.
@@ -139,6 +139,9 @@ class ParallelScavengeHeap : public CollectedHeap { | |||
// Returns JNI_OK on success | |||
virtual jint initialize(); | |||
|
|||
void safepoint_synchronize_begin(); | |||
void safepoint_synchronize_end(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, never mind. These are overriding virtual function declarations. Please add virtual
. The modern style would be to use override
, but gcc warns if some but not all of a class's overridden virtual functions use override
, and you probably don't want to do that update for this class as part of this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
@@ -286,10 +286,8 @@ inline oop PSPromotionManager::copy_unmarked_to_survivor_space(oop o, | |||
// we'll just push its contents | |||
push_contents(new_obj); | |||
|
|||
if (psStringDedup::is_candidate_from_evacuation(o->klass(), new_obj->age(), new_obj_is_tenured)) { | |||
if (!java_lang_String::test_and_set_deduplication_requested(o)) { | |||
if (psStringDedup::is_candidate_from_evacuation(new_obj, new_obj_is_tenured)) { | |||
_string_dedup_requests.add(o); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update indentation? Or is github not showing the whitespace-only change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to update the indentation! Thanks
@walulyai 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:
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 84 new commits pushed to the
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest look fine.
// Candidate if string is being evacuated from young to old but has not | ||
// reached the deduplication age threshold, i.e. has not previously been a | ||
// candidate during its life in the young generation. | ||
return PSParallelCompact::space_id(cast_from_oop<HeapWord*>(java_string)) > PSParallelCompact::old_space_id && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the space-id comparison can be replaced with sth like PSScavenge::is_obj_in_young(java_string)
; we are checking if this java_string
live in young-gen, right?
#ifndef SHARE_GC_PARALLEL_PSSTRINGDEDUP_HPP | ||
#define SHARE_GC_PARALLEL_PSSTRINGDEDUP_HPP | ||
|
||
#include "classfile/javaClasses.inline.hpp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
".inline.hpp" files must not be included by ".hpp" files.
// Candidate selection policy for young during evacuation. | ||
// If to is young then age should be the new (survivor's) age. | ||
// if to is old then age should be the age of the copied from object. | ||
static bool is_candidate_from_evacuation(oop obj, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was just copied from G1 and isn't right for this implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leftover from an earlier version, fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Thanks @albertnetymk and @kimbarrett for the reviews! /integrate |
Going to push as commit fb1dfc6.
Your commit was automatically rebased without conflicts. |
Hi all,
Please review this change to add string deduplication support to ParallelGC.
Testing: All string deduplication tests, and Tier 1-5.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5085/head:pull/5085
$ git checkout pull/5085
Update a local copy of the PR:
$ git checkout pull/5085
$ git pull https://git.openjdk.java.net/jdk pull/5085/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 5085
View PR using the GUI difftool:
$ git pr show -t 5085
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5085.diff