From c3021de8db283d3d113086fe6e4a32d70d8f13d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=B9=8F?= Date: Mon, 18 Aug 2025 11:44:31 +0800 Subject: [PATCH] Revert "[CMC] fix resident memory problem" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit f838e67d5bcb5866a0d87f2311d4b7ef19e125fb. Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/ICTG92 Change-Id: Ie63ced833b029972190e524ce69bb39dea445667 Signed-off-by: 张鹏 --- .../common_runtime/base_runtime_param.cpp | 4 ---- .../common_runtime/base_runtime_param.h | 4 +--- common_components/heap/allocator/region_space.cpp | 1 - common_components/heap/allocator/region_space.h | 4 ---- .../heap/collector/marking_collector.cpp | 2 +- ecmascript/js_runtime_options.cpp | 15 --------------- ecmascript/js_runtime_options.h | 13 ------------- ecmascript/mem/mem.h | 1 - ecmascript/platform/common/parameters.cpp | 5 ----- ecmascript/platform/parameters.h | 2 -- ecmascript/platform/unix/ohos/parameters.cpp | 9 --------- ecmascript/runtime.cpp | 3 --- 12 files changed, 2 insertions(+), 61 deletions(-) diff --git a/common_components/common_runtime/base_runtime_param.cpp b/common_components/common_runtime/base_runtime_param.cpp index 19f3ffa215..51db0d92b0 100755 --- a/common_components/common_runtime/base_runtime_param.cpp +++ b/common_components/common_runtime/base_runtime_param.cpp @@ -32,10 +32,6 @@ void BaseRuntimeParam::SetConfigHeapSize(RuntimeParam ¶m, size_t configHeapS param.heapParam.heapSize = std::min(configHeapSize, MAX_HEAP_POOL_SIZE) / KB; } -void BaseRuntimeParam::SetMaxGarbageCacheSize(RuntimeParam ¶m, uint64_t maxGarbageCacheSize) -{ - param.gcParam.maxGarbageCacheSize = maxGarbageCacheSize; -} /** * Determine the default stack size and heap size according to system memory. * If system memory size is less then 1GB, heap size is 64MB and stack size is 64KB. diff --git a/common_components/common_runtime/base_runtime_param.h b/common_components/common_runtime/base_runtime_param.h index a55a608aa1..d8b68cd2e6 100755 --- a/common_components/common_runtime/base_runtime_param.h +++ b/common_components/common_runtime/base_runtime_param.h @@ -26,7 +26,6 @@ public: static RuntimeParam DefaultRuntimeParam(); static size_t InitHeapSize(); static void SetConfigHeapSize(RuntimeParam ¶m, size_t configHeapSize); - static void SetMaxGarbageCacheSize(RuntimeParam ¶m, uint64_t maxGarbageCacheSize); #ifdef PANDA_TARGET_32 static constexpr size_t MAX_HEAP_POOL_SIZE = 1 * GB; #else @@ -66,8 +65,7 @@ private: V(gcParam, kMinConcurrentRemainingBytes, \ size_t, 0, INT64_MAX, 128 * KB ) /* byte */; \ V(gcParam, kMaxConcurrentRemainingBytes, \ - size_t, 0, INT64_MAX, 512 * KB ) /* byte */; \ - V(gcParam, maxGarbageCacheSize, uint64_t, 0, INT64_MAX, 16 * MB ) /* byte */; + size_t, 0, INT64_MAX, 512 * KB ) /* byte */; #else // PANDA_TARGET_OHOS #define RUNTIME_PARAM_LIST(V) \ /* KEY SUB_KEY TYPE MIN MAX DEFAULT */ /* UNIT */ \ diff --git a/common_components/heap/allocator/region_space.cpp b/common_components/heap/allocator/region_space.cpp index 4b797382c4..9dc16d17f1 100755 --- a/common_components/heap/allocator/region_space.cpp +++ b/common_components/heap/allocator/region_space.cpp @@ -288,7 +288,6 @@ void RegionSpace::Init(const RuntimeParam& param) MemoryMap::Option opt = MemoryMap::DEFAULT_OPTIONS; opt.tag = "region_heap"; size_t heapSize = param.heapParam.heapSize * KB; - maxGarbageCacheSize_ = param.gcParam.maxGarbageCacheSize; #ifndef PANDA_TARGET_32 static constexpr uint64_t MAX_SUPPORT_CAPACITY = 4ULL * GB; diff --git a/common_components/heap/allocator/region_space.h b/common_components/heap/allocator/region_space.h index be67860f26..ac4df4b83b 100755 --- a/common_components/heap/allocator/region_space.h +++ b/common_components/heap/allocator/region_space.h @@ -186,9 +186,6 @@ public: size_t size = GetAllocatedBytes(); double cachedRatio = 1 - BaseRuntime::GetInstance()->GetHeapParam().heapUtilization; size_t targetCachedSize = static_cast(size * cachedRatio); - if (targetCachedSize > maxGarbageCacheSize_) { - targetCachedSize = maxGarbageCacheSize_; - } return regionManager_.ReleaseGarbageRegions(targetCachedSize); } } @@ -407,7 +404,6 @@ private: FromSpace fromSpace_; ToSpace toSpace_; - uint64_t maxGarbageCacheSize_ { 16 * MB }; }; using RegionalHeap = RegionSpace; diff --git a/common_components/heap/collector/marking_collector.cpp b/common_components/heap/collector/marking_collector.cpp index db58ee4bbc..b72627089f 100755 --- a/common_components/heap/collector/marking_collector.cpp +++ b/common_components/heap/collector/marking_collector.cpp @@ -727,7 +727,7 @@ void MarkingCollector::CopyObject(const BaseObject& fromObj, BaseObject& toObj, void MarkingCollector::ReclaimGarbageMemory(GCReason reason) { - if (reason != GC_REASON_YOUNG) { + if (reason == GC_REASON_OOM) { Heap::GetHeap().GetAllocator().ReclaimGarbageMemory(true); } else { Heap::GetHeap().GetAllocator().ReclaimGarbageMemory(false); diff --git a/ecmascript/js_runtime_options.cpp b/ecmascript/js_runtime_options.cpp index 5a91a574e4..33582f0066 100644 --- a/ecmascript/js_runtime_options.cpp +++ b/ecmascript/js_runtime_options.cpp @@ -87,7 +87,6 @@ const std::string PUBLIC_API HELP_OPTION_MSG = #else "--enable-cmc-gc: Enable cmc gc. Default: 'false'\n" #endif - "--cmc-max-garbage-cache-size: Max size of cmc gc garbage cache.. Default: 16M\n" "--enable-cmc-gc-concurrent-root-marking: Enable concurrent root marking in cmc gc. Default: 'true'\n" "--force-shared-gc-frequency: How frequency force shared gc . Default: '1'\n" "--enable-ic: Switch of inline cache. Default: 'true'\n" @@ -259,7 +258,6 @@ bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv) {"enable-loading-stubs-log", required_argument, nullptr, OPTION_ENABLE_LOADING_STUBS_LOG}, {"enable-force-gc", required_argument, nullptr, OPTION_ENABLE_FORCE_GC}, {"enable-cmc-gc", required_argument, nullptr, OPTION_ENABLE_CMC_GC}, - {"cmc-max-garbage-cache-size", required_argument, nullptr, OPTION_MAX_GARBAGE_CACHE_SIZE}, {"enable-cmc-gc-concurrent-root-marking", required_argument, nullptr, OPTION_ENABLE_CMC_GC_CONCURRENT_ROOT_MARKING}, {"enable-ic", required_argument, nullptr, OPTION_ENABLE_IC}, @@ -627,14 +625,6 @@ bool JSRuntimeOptions::ParseCommand(const int argc, const char **argv) return false; } break; - case OPTION_MAX_GARBAGE_CACHE_SIZE: - ret = ParseUint64Param("cmc-max-garbage-cache-size", &argUInt64); - if (ret) { - SetCMCMaxGarbageCacheSize(argUInt64); - } else { - return false; - } - break; case OPTION_ENABLE_CMC_GC_CONCURRENT_ROOT_MARKING: ret = ParseBoolParam(&argBool); if (ret) { @@ -1752,11 +1742,6 @@ void JSRuntimeOptions::SetConfigHeapSize(size_t configHeapSize) common::BaseRuntimeParam::SetConfigHeapSize(param_, configHeapSize); } -void JSRuntimeOptions::SetConfigMaxGarbageCacheSize(uint64_t maxGarbageCacheSize) -{ - common::BaseRuntimeParam::SetMaxGarbageCacheSize(param_, maxGarbageCacheSize); -} - void JSRuntimeOptions::SetMemConfigProperty(const std::string &configProperty) { if (configProperty == "openArkTools") { diff --git a/ecmascript/js_runtime_options.h b/ecmascript/js_runtime_options.h index f0775e920e..da92db275b 100644 --- a/ecmascript/js_runtime_options.h +++ b/ecmascript/js_runtime_options.h @@ -96,7 +96,6 @@ enum CommandValues { OPTION_STUB_FILE, OPTION_ENABLE_FORCE_GC, OPTION_ENABLE_CMC_GC, - OPTION_MAX_GARBAGE_CACHE_SIZE, OPTION_ENABLE_CMC_GC_CONCURRENT_ROOT_MARKING, OPTION_FORCE_FULL_GC, OPTION_ENABLE_FORCE_SHARED_GC_FREQUENCY, @@ -295,7 +294,6 @@ public: bool ParseCommand(const int argc, const char** argv); bool SetDefaultValue(char* argv); - void SetConfigMaxGarbageCacheSize(uint64_t maxGarbageCacheSize); bool EnableArkTools() const { @@ -2187,16 +2185,6 @@ public: return CompilerAnFileMaxByteSize_; } - void SetCMCMaxGarbageCacheSize(uint64_t value) - { - cmcMaxGarbageCacheSize_ = value; - } - - uint64_t GetCMCMaxGarbageCacheSize() const - { - return cmcMaxGarbageCacheSize_; - } - bool IsCompilerAnFileMaxByteSizeDefault() const { return CompilerAnFileMaxByteSize_ == 0; @@ -2583,7 +2571,6 @@ private: bool enableCMCGCConcurrentRootMarking_ {true}; bool storeBarrierOpt_ {true}; uint64_t CompilerAnFileMaxByteSize_ {0_MB}; - uint64_t cmcMaxGarbageCacheSize_ {16_MB}; bool enableJitVerifyPass_ {true}; bool enableMergePoly_ {true}; bool multiContext_ {false}; diff --git a/ecmascript/mem/mem.h b/ecmascript/mem/mem.h index ba98cf9821..664be1d482 100644 --- a/ecmascript/mem/mem.h +++ b/ecmascript/mem/mem.h @@ -85,7 +85,6 @@ static constexpr size_t MAX_32BIT_OBJECT_SPACE_SIZE = 1_GB; static constexpr size_t MAX_REGULAR_HEAP_OBJECT_SIZE_FOR_CMC = 32_KB; // initialize from CMC-GC static constexpr size_t MAX_REGULAR_HEAP_OBJECT_SIZE = DEFAULT_REGION_SIZE * 2 / 3; inline size_t g_maxRegularHeapObjectSize = MAX_REGULAR_HEAP_OBJECT_SIZE; -inline uint64_t g_maxGarbageCacheSize = 16_MB; // internal allocator static constexpr size_t CHUNK_ALIGN_SIZE = 4_KB; static constexpr size_t MIN_CHUNK_AREA_SIZE = 4_KB; diff --git a/ecmascript/platform/common/parameters.cpp b/ecmascript/platform/common/parameters.cpp index 2f98f08b7f..a6556e2e73 100644 --- a/ecmascript/platform/common/parameters.cpp +++ b/ecmascript/platform/common/parameters.cpp @@ -30,9 +30,4 @@ namespace panda::ecmascript { { return defaultValue; } - - uint64_t GetCMCMaxGarbageCacheSize(uint64_t defaultSize) - { - return defaultSize; - } } // namespace panda::ecmascript diff --git a/ecmascript/platform/parameters.h b/ecmascript/platform/parameters.h index 8d8793facc..b5b560687e 100644 --- a/ecmascript/platform/parameters.h +++ b/ecmascript/platform/parameters.h @@ -26,7 +26,5 @@ namespace panda::ecmascript { size_t GetPoolSize(size_t defaultSize); bool IsEnableCMCGC(bool defaultValue); - - uint64_t GetCMCMaxGarbageCacheSize(uint64_t defaultSize); } // namespace panda::ecmascript #endif // ECMASCRIPT_PLATFORM_PARAMETERS_H diff --git a/ecmascript/platform/unix/ohos/parameters.cpp b/ecmascript/platform/unix/ohos/parameters.cpp index a3274e4275..48975ca478 100644 --- a/ecmascript/platform/unix/ohos/parameters.cpp +++ b/ecmascript/platform/unix/ohos/parameters.cpp @@ -45,15 +45,6 @@ namespace panda::ecmascript { return OHOS::system::GetBoolParameter("persist.ark.enable.cmc.gc", defaultValue); #else return defaultValue; -#endif - } - - uint64_t GetCMCMaxGarbageCacheSize(uint64_t defaultSize) - { -#if !defined(STANDALONE_MODE) - return OHOS::system::GetUintParameter("persist.ark.cmc.max.garbage.cache.size", defaultSize); -#else - return defaultSize; #endif } } // namespace panda::ecmascript diff --git a/ecmascript/runtime.cpp b/ecmascript/runtime.cpp index 779564acd4..cb3a747b13 100644 --- a/ecmascript/runtime.cpp +++ b/ecmascript/runtime.cpp @@ -88,7 +88,6 @@ void Runtime::CreateIfFirstVm(const JSRuntimeOptions &options) LOG_ECMA(INFO) << "start run with cmc gc"; // SetConfigHeapSize for cmc gc, pc and persist config may change heap size. const_cast(options).SetConfigHeapSize(MemMapAllocator::GetInstance()->GetCapacity()); - const_cast(options).SetConfigMaxGarbageCacheSize(g_maxGarbageCacheSize); common::BaseRuntime::GetInstance()->Init(options.GetRuntimeParam()); common::g_enableGCTimeoutCheck = options.IsEnableGCTimeoutCheck(); #if defined(ECMASCRIPT_SUPPORT_HEAPPROFILER) @@ -181,8 +180,6 @@ void Runtime::InitGCConfig(const JSRuntimeOptions &options) g_isEnableCMCGC = IsEnableCMCGC(defaultValue); if (g_isEnableCMCGC) { g_maxRegularHeapObjectSize = 32_KB; - uint64_t defaultSize = options.GetCMCMaxGarbageCacheSize(); - g_maxGarbageCacheSize = GetCMCMaxGarbageCacheSize(defaultSize); } g_isEnableCMCGCConcurrentRootMarking = options.IsEnableCMCGCConcurrentRootMarking(); } -- Gitee