From 6cd166a2841cc97f458b579d89a37282f73c6ba9 Mon Sep 17 00:00:00 2001 From: Guoxiong Li Date: Mon, 12 Jun 2023 15:52:08 +0000 Subject: [PATCH] 8309403: Serial: Remove the useless adaptive size policy in GenCollectedHeap Reviewed-by: ayang, tschatzl --- .../share/gc/serial/defNewGeneration.cpp | 4 -- .../share/gc/shared/genCollectedHeap.cpp | 18 +-------- .../share/gc/shared/genCollectedHeap.hpp | 18 ++------- .../share/gc/shared/softRefGenPolicy.cpp | 40 ------------------- .../share/gc/shared/softRefGenPolicy.hpp | 38 ------------------ src/hotspot/share/prims/whitebox.cpp | 8 ++-- 6 files changed, 8 insertions(+), 118 deletions(-) delete mode 100644 src/hotspot/share/gc/shared/softRefGenPolicy.cpp delete mode 100644 src/hotspot/share/gc/shared/softRefGenPolicy.hpp diff --git a/src/hotspot/share/gc/serial/defNewGeneration.cpp b/src/hotspot/share/gc/serial/defNewGeneration.cpp index bd256c9c555..4d0d01b8fa3 100644 --- a/src/hotspot/share/gc/serial/defNewGeneration.cpp +++ b/src/hotspot/share/gc/serial/defNewGeneration.cpp @@ -830,10 +830,6 @@ void DefNewGeneration::collect(bool full, adjust_desired_tenuring_threshold(); - // A successful scavenge should restart the GC time limit count which is - // for full GC's. - AdaptiveSizePolicy* size_policy = heap->size_policy(); - size_policy->reset_gc_overhead_limit_count(); assert(!heap->incremental_collection_failed(), "Should be clear"); } else { assert(_promo_failure_scan_stack.is_empty(), "post condition"); diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp index 36f229ab817..5e416d99472 100644 --- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp +++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp @@ -95,8 +95,7 @@ GenCollectedHeap::GenCollectedHeap(Generation::Name young, MaxOldSize, GenAlignment)), _rem_set(nullptr), - _soft_ref_gen_policy(), - _size_policy(nullptr), + _soft_ref_policy(), _gc_policy_counters(new GCPolicyCounters(policy_counters_name, 2, 2)), _incremental_collection_failed(false), _full_collections_completed(0), @@ -139,17 +138,6 @@ CardTableRS* GenCollectedHeap::create_rem_set(const MemRegion& reserved_region) return new CardTableRS(reserved_region); } -void GenCollectedHeap::initialize_size_policy(size_t init_eden_size, - size_t init_promo_size, - size_t init_survivor_size) { - const double max_gc_pause_sec = ((double) MaxGCPauseMillis) / 1000.0; - _size_policy = new AdaptiveSizePolicy(init_eden_size, - init_promo_size, - init_survivor_size, - max_gc_pause_sec, - GCTimeRatio); -} - ReservedHeapSpace GenCollectedHeap::allocate(size_t alignment) { // Now figure out the total size. const size_t pageSize = UseLargePages ? os::large_page_size() : os::vm_page_size(); @@ -194,10 +182,6 @@ void GenCollectedHeap::post_initialize() { def_new_gen->ref_processor_init(); - initialize_size_policy(def_new_gen->eden()->capacity(), - _old_gen->capacity(), - def_new_gen->from()->capacity()); - MarkSweep::initialize(); ScavengableNMethods::initialize(&_is_scavengable); diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.hpp b/src/hotspot/share/gc/shared/genCollectedHeap.hpp index f279c7588de..6d6b54f69ce 100644 --- a/src/hotspot/share/gc/shared/genCollectedHeap.hpp +++ b/src/hotspot/share/gc/shared/genCollectedHeap.hpp @@ -29,7 +29,7 @@ #include "gc/shared/generation.hpp" #include "gc/shared/oopStorageParState.hpp" #include "gc/shared/preGCValues.hpp" -#include "gc/shared/softRefGenPolicy.hpp" +#include "gc/shared/softRefPolicy.hpp" class AdaptiveSizePolicy; class CardTableRS; @@ -72,10 +72,7 @@ private: // The singleton CardTable Remembered Set. CardTableRS* _rem_set; - SoftRefGenPolicy _soft_ref_gen_policy; - - // The sizing of the heap is controlled by a sizing policy. - AdaptiveSizePolicy* _size_policy; + SoftRefPolicy _soft_ref_policy; GCPolicyCounters* _gc_policy_counters; @@ -139,10 +136,6 @@ public: jint initialize() override; virtual CardTableRS* create_rem_set(const MemRegion& reserved_region); - void initialize_size_policy(size_t init_eden_size, - size_t init_promo_size, - size_t init_survivor_size); - // Does operations required after initialization has been done. void post_initialize() override; @@ -158,12 +151,7 @@ public: GenerationSpec* young_gen_spec() const; GenerationSpec* old_gen_spec() const; - SoftRefPolicy* soft_ref_policy() override { return &_soft_ref_gen_policy; } - - // Adaptive size policy - virtual AdaptiveSizePolicy* size_policy() { - return _size_policy; - } + SoftRefPolicy* soft_ref_policy() override { return &_soft_ref_policy; } // Performance Counter support GCPolicyCounters* counters() { return _gc_policy_counters; } diff --git a/src/hotspot/share/gc/shared/softRefGenPolicy.cpp b/src/hotspot/share/gc/shared/softRefGenPolicy.cpp deleted file mode 100644 index 1f09aaedfcc..00000000000 --- a/src/hotspot/share/gc/shared/softRefGenPolicy.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. 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/shared/adaptiveSizePolicy.hpp" -#include "gc/shared/genCollectedHeap.hpp" -#include "gc/shared/softRefGenPolicy.hpp" - -void SoftRefGenPolicy::cleared_all_soft_refs() { - // If near gc overhear limit, continue to clear SoftRefs. SoftRefs may - // have been cleared in the last collection but if the gc overhear - // limit continues to be near, SoftRefs should still be cleared. - AdaptiveSizePolicy* size_policy = GenCollectedHeap::heap()->size_policy(); - if (size_policy != nullptr) { - set_should_clear_all_soft_refs(size_policy->gc_overhead_limit_near()); - } - - SoftRefPolicy::cleared_all_soft_refs(); -} diff --git a/src/hotspot/share/gc/shared/softRefGenPolicy.hpp b/src/hotspot/share/gc/shared/softRefGenPolicy.hpp deleted file mode 100644 index 97246d1c222..00000000000 --- a/src/hotspot/share/gc/shared/softRefGenPolicy.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. 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_SHARED_SOFTREFGENPOLICY_HPP -#define SHARE_GC_SHARED_SOFTREFGENPOLICY_HPP - -#include "gc/shared/softRefPolicy.hpp" -#include "utilities/globalDefinitions.hpp" - -class AdaptiveSizePolicy; - -class SoftRefGenPolicy : public SoftRefPolicy { -public: - virtual void cleared_all_soft_refs(); -}; - -#endif // SHARE_GC_SHARED_SOFTREFGENPOLICY_HPP diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index a1a0237765c..e03856cbab6 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -1445,12 +1445,12 @@ WB_END WB_ENTRY(void, WB_FullGC(JNIEnv* env, jobject o)) Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(true); Universe::heap()->collect(GCCause::_wb_full_gc); -#if INCLUDE_G1GC - if (UseG1GC) { - // Needs to be cleared explicitly for G1 +#if INCLUDE_G1GC || INCLUDE_SERIALGC + if (UseG1GC || UseSerialGC) { + // Needs to be cleared explicitly for G1 and Serial GC. Universe::heap()->soft_ref_policy()->set_should_clear_all_soft_refs(false); } -#endif // INCLUDE_G1GC +#endif // INCLUDE_G1GC || INCLUDE_SERIALGC WB_END WB_ENTRY(void, WB_YoungGC(JNIEnv* env, jobject o))