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
8272609: Add string deduplication support to SerialGC #5153
Changes from all commits
6d6f3d9
5b9a553
d7a7c68
564612e
e8bb9e8
e4c7fd2
1ae4e45
86da544
bb4cdfe
077ca27
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,6 +112,8 @@ void GenMarkSweep::invoke_at_safepoint(ReferenceProcessor* rp, bool clear_all_so | |
|
||
deallocate_stacks(); | ||
|
||
MarkSweep::_string_dedup_requests->flush(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your review and Kim's detailed explanation. I think putting this invocation here or the position you suggest should have no effect on the result, so I tend not to make this modification. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe it's desirable to narrow the request window (btw first There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer it where it is. Rather than putting something between phantom There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still think |
||
|
||
// If compaction completely evacuated the young generation then we | ||
// can clear the card table. Otherwise, we must invalidate | ||
// it (consider all cards dirty). In the future, we might consider doing | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,8 @@ ReferenceProcessor* MarkSweep::_ref_processor = NULL; | |
STWGCTimer* MarkSweep::_gc_timer = NULL; | ||
SerialOldTracer* MarkSweep::_gc_tracer = NULL; | ||
|
||
StringDedup::Requests* MarkSweep::_string_dedup_requests = NULL; | ||
|
||
MarkSweep::FollowRootClosure MarkSweep::follow_root_closure; | ||
|
||
MarkAndPushClosure MarkSweep::mark_and_push_closure; | ||
|
@@ -214,4 +216,5 @@ void MarkSweep::KeepAliveClosure::do_oop(narrowOop* p) { MarkSweep::KeepAliveClo | |
void MarkSweep::initialize() { | ||
MarkSweep::_gc_timer = new (ResourceObj::C_HEAP, mtGC) STWGCTimer(); | ||
MarkSweep::_gc_tracer = new (ResourceObj::C_HEAP, mtGC) SerialOldTracer(); | ||
MarkSweep::_string_dedup_requests = new StringDedup::Requests(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not clear to me why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a non-local variable with a non-trivial destructor. See |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (c) 2021, Alibaba Group Holding Limited. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
#include "precompiled.hpp" | ||
#include "gc/serial/defNewGeneration.hpp" | ||
#include "gc/serial/serialHeap.hpp" | ||
#include "gc/serial/serialStringDedup.hpp" | ||
#include "oops/oop.inline.hpp" | ||
|
||
bool SerialStringDedup::is_candidate_from_mark(oop java_string) { | ||
// 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 SerialHeap::heap()->young_gen()->is_in_reserved(java_string) && | ||
StringDedup::is_below_threshold_age(java_string->age()); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright (c) 2021, Alibaba Group Holding Limited. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
#ifndef SHARE_GC_SERIAL_STRINGDEDUP_HPP | ||
#define SHARE_GC_SERIAL_STRINGDEDUP_HPP | ||
|
||
#include "memory/allStatic.hpp" | ||
#include "oops/oopsHierarchy.hpp" | ||
|
||
class SerialStringDedup : AllStatic { | ||
public: | ||
|
||
// Candidate selection policy for full GC, returning true if the given | ||
// String is a candidate for string deduplication. | ||
// precondition: StringDedup::is_enabled() | ||
// precondition: java_string is a Java String | ||
static bool is_candidate_from_mark(oop java_string); | ||
|
||
// Candidate selection policy for young during evacuation. | ||
static inline bool is_candidate_from_evacuation(oop obj, bool obj_is_tenured); | ||
|
||
}; | ||
|
||
#endif // SHARE_GC_SERIAL_STRINGDEDUP_HPP | ||
D-D-H marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2021, Alibaba Group Holding Limited. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
#ifndef SHARE_GC_SERIAL_STRINGDEDUP_INLINE_HPP | ||
#define SHARE_GC_SERIAL_STRINGDEDUP_INLINE_HPP | ||
|
||
#include "gc/serial/serialStringDedup.hpp" | ||
D-D-H marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#include "classfile/javaClasses.inline.hpp" | ||
#include "oops/oop.inline.hpp" | ||
|
||
bool SerialStringDedup::is_candidate_from_evacuation(oop obj, | ||
bool obj_is_tenured) { | ||
return StringDedup::is_enabled() && | ||
java_lang_String::is_instance_inlined(obj) && | ||
(obj_is_tenured ? | ||
StringDedup::is_below_threshold_age(obj->age()) : | ||
StringDedup::is_threshold_age(obj->age())); | ||
} | ||
|
||
#endif // SHARE_GC_SERIAL_STRINGDEDUP_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.
I wonder if placing
_string_dedup_requests.flush();
before weak roots processing (WeakProcessor::weak_oops_do
) makes more senses. The documentation saysflush
should be called when marking is done; for Serial young GC, it's equivalent to when evacuation is done, which is right after ref-processing.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.
That documentation is mistaken; that's a left-over from an earlier development version that I forgot to update. Without special additional care, the lifetime also needs to cover final-reference processing. I have a todo item to file a bug against that comment.