From 2071ae8482c7496c8b0609780c14c4aebf3fb4e1 Mon Sep 17 00:00:00 2001 From: Younes Manton Date: Mon, 11 Nov 2024 10:15:13 -0800 Subject: [PATCH 1/3] Increase SCC disclaim frequency This patch reduces minTimeBetweenMemoryDisclaims from 5000 to 500 and increases the time between disclaims for the data cache, code cache, and iprofiler data by a factor of 10 to maintain the current behavior. For the SCC it removes the scaling of minTimeBetweenMemoryDisclaims such that we will disclaim the SCC every 500 ms. Signed-off-by: Younes Manton --- runtime/compiler/control/HookedByTheJit.cpp | 12 ++++++------ runtime/compiler/control/J9Options.cpp | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/runtime/compiler/control/HookedByTheJit.cpp b/runtime/compiler/control/HookedByTheJit.cpp index 7afbc075a14..966c91dca83 100644 --- a/runtime/compiler/control/HookedByTheJit.cpp +++ b/runtime/compiler/control/HookedByTheJit.cpp @@ -4613,7 +4613,7 @@ void memoryDisclaimLogic(TR::CompilationInfo *compInfo, uint64_t crtElapsedTime, if (sharedCache && sharedCache->isDisclaimEnabled()) { // Disclaim if there was a large time interval since the last disclaim - if (crtElapsedTime > lastSCCDisclaimTime + 12 * TR::Options::_minTimeBetweenMemoryDisclaims) + if (crtElapsedTime > lastSCCDisclaimTime + TR::Options::_minTimeBetweenMemoryDisclaims) { disclaimSharedClassCache(sharedCache, crtElapsedTime); lastSCCDisclaimTime = crtElapsedTime; @@ -4624,12 +4624,12 @@ void memoryDisclaimLogic(TR::CompilationInfo *compInfo, uint64_t crtElapsedTime, if (TR_DataCacheManager::getManager()->isDisclaimEnabled()) { // Ensure we don't do it too often - if (crtElapsedTime > lastDataCacheDisclaimTime + TR::Options::_minTimeBetweenMemoryDisclaims) + if (crtElapsedTime > lastDataCacheDisclaimTime + 10 * TR::Options::_minTimeBetweenMemoryDisclaims) { // Disclaim if at least one data cache has been allocated since the last disclaim // or if there was a large time interval since the last disclaim if (TR_DataCacheManager::getManager()->numAllocatedCaches() > lastNumAllocatedDataCaches || - crtElapsedTime > lastDataCacheDisclaimTime + 12 * TR::Options::_minTimeBetweenMemoryDisclaims) + crtElapsedTime > lastDataCacheDisclaimTime + 120 * TR::Options::_minTimeBetweenMemoryDisclaims) { disclaimDataCaches(crtElapsedTime); lastDataCacheDisclaimTime = crtElapsedTime; // Update the time when disclaim was last performed @@ -4642,12 +4642,12 @@ void memoryDisclaimLogic(TR::CompilationInfo *compInfo, uint64_t crtElapsedTime, if (TR::CodeCacheManager::instance()->isDisclaimEnabled()) { // Ensure we don't do it too often - if (crtElapsedTime > lastCodeCacheDisclaimTime + TR::Options::_minTimeBetweenMemoryDisclaims) + if (crtElapsedTime > lastCodeCacheDisclaimTime + 10 * TR::Options::_minTimeBetweenMemoryDisclaims) { // Disclaim if at least one code cache has been allocated since the last disclaim // or if there was a large time interval since the last disclaim if (TR::CodeCacheManager::instance()->getCurrentNumberOfCodeCaches() > lastNumAllocatedCodeCaches || - crtElapsedTime > lastCodeCacheDisclaimTime + 12 * TR::Options::_minTimeBetweenMemoryDisclaims) + crtElapsedTime > lastCodeCacheDisclaimTime + 120 * TR::Options::_minTimeBetweenMemoryDisclaims) { static OMR::RSSReport *rssReport = OMR::RSSReport::instance(); @@ -4673,7 +4673,7 @@ void memoryDisclaimLogic(TR::CompilationInfo *compInfo, uint64_t crtElapsedTime, TR::PersistentAllocator * iprofilerAllocator = TR_IProfiler::allocator(); if (iprofilerAllocator->isDisclaimEnabled()) { - if (crtElapsedTime > lastIProfilerDisclaimTime + TR::Options::_minTimeBetweenMemoryDisclaims && + if (crtElapsedTime > lastIProfilerDisclaimTime + 10 * TR::Options::_minTimeBetweenMemoryDisclaims && // Avoid disclaiming IProfiler segments if IProfiler is still active returnIprofilerState() == IPROFILING_STATE_OFF && // Avoid disclaiming if compilations are still to pe performed diff --git a/runtime/compiler/control/J9Options.cpp b/runtime/compiler/control/J9Options.cpp index 78bba845c29..8399d157c8b 100644 --- a/runtime/compiler/control/J9Options.cpp +++ b/runtime/compiler/control/J9Options.cpp @@ -216,7 +216,7 @@ int32_t J9::Options::_TLHPrefetchStaggeredLineCount = 0; int32_t J9::Options::_TLHPrefetchBoundaryLineCount = 0; int32_t J9::Options::_TLHPrefetchTLHEndLineCount = 0; -int32_t J9::Options::_minTimeBetweenMemoryDisclaims = 5000; // ms +int32_t J9::Options::_minTimeBetweenMemoryDisclaims = 500; // ms int32_t J9::Options::_numFirstTimeCompilationsToExitIdleMode = 25; // Use a large number to disable the feature int32_t J9::Options::_waitTimeToEnterIdleMode = 5000; // ms @@ -1120,7 +1120,7 @@ TR::OptionTable OMR::Options::_feOptions[] = { {"minSuperclassArraySize=", "I\t set the size of the minimum superclass array size", TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_minimumSuperclassArraySize, 0, "F%d", NOT_IN_SUBSET}, {"minTimeBetweenMemoryDisclaims=", "M\tMinimum time (ms) between two consecutive memory disclaim operations", - TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_minTimeBetweenMemoryDisclaims, 5000, "F%d", NOT_IN_SUBSET}, + TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_minTimeBetweenMemoryDisclaims, 500, "F%d", NOT_IN_SUBSET}, {"noregmap", 0, RESET_JITCONFIG_RUNTIME_FLAG(J9JIT_CG_REGISTER_MAPS) }, {"numCodeCachesOnStartup=", "R\tnumber of code caches to create at startup", TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_numCodeCachesToCreateAtStartup, 0, "F%d", NOT_IN_SUBSET}, From 32d32bcd94996df72dc6ca7b7375f8a67db80b9f Mon Sep 17 00:00:00 2001 From: Younes Manton Date: Mon, 11 Nov 2024 15:36:29 -0800 Subject: [PATCH 2/3] Enable SCC disclaim when CRIU or CRaC is enabled This patch enables SCC disclaiming when CRIU or CRaC support is enabled. Signed-off-by: Younes Manton --- runtime/compiler/control/J9Options.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/runtime/compiler/control/J9Options.cpp b/runtime/compiler/control/J9Options.cpp index 8399d157c8b..134744428c9 100644 --- a/runtime/compiler/control/J9Options.cpp +++ b/runtime/compiler/control/J9Options.cpp @@ -2605,6 +2605,11 @@ J9::Options::fePreProcess(void * base) } } +#if defined(J9VM_OPT_CRIU_SUPPORT) + if (vm->internalVMFunctions->isCRaCorCRIUSupportEnabled(vm)) + self()->setOption(TR_EnableSharedCacheDisclaiming); +#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ + int32_t xxEnableTrackAOTDependenciesArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, J9::Options::_externalOptionStrings[J9::ExternalOptions::XXplusTrackAOTDependencies], 0); int32_t xxDisableTrackAOTDependenciesArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, J9::Options::_externalOptionStrings[J9::ExternalOptions::XXminusTrackAOTDependencies], 0); if (xxEnableTrackAOTDependenciesArgIndex > xxDisableTrackAOTDependenciesArgIndex) @@ -2773,6 +2778,7 @@ J9::Options::fePreProcess(void * base) self()->setOption(TR_DisableDataCacheDisclaiming); self()->setOption(TR_DisableIProfilerDataDisclaiming); self()->setOption(TR_EnableCodeCacheDisclaiming, false); + self()->setOption(TR_EnableSharedCacheDisclaiming, false); } return true; From 0aab9d671b30c5070ea7cd24f45e1886c9f652d7 Mon Sep 17 00:00:00 2001 From: Younes Manton Date: Mon, 11 Nov 2024 15:39:51 -0800 Subject: [PATCH 3/3] Scale DNSS expected ratio min/max 2x for InstantOn This patch scales dnssExpectedRatioMaximum and dnssExpectedRatioMinimum by 2x when neither is user-specified and either CRIU or CRaC support is enabled. This favours reduced memory consumption at the expense of GC overhead. Signed-off-by: Younes Manton --- runtime/gc_glue_java/ConfigurationDelegate.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/runtime/gc_glue_java/ConfigurationDelegate.hpp b/runtime/gc_glue_java/ConfigurationDelegate.hpp index effc85cc482..d4856b4a6e7 100644 --- a/runtime/gc_glue_java/ConfigurationDelegate.hpp +++ b/runtime/gc_glue_java/ConfigurationDelegate.hpp @@ -117,6 +117,22 @@ class MM_ConfigurationDelegate if (!_extensions->dynamicClassUnloadingKickoffThresholdForced) { _extensions->dynamicClassUnloadingKickoffThreshold = DYNAMIC_CLASS_UNLOADING_KICKOFF_THRESHOLD; } + +#if defined(J9VM_OPT_CRIU_SUPPORT) + /* Favour reduced memory consumption over pause times when checkpointing is enabled by + * scaling the default min and max DNSS expected ratios by a constant factor, unless + * at least one ratio was directly specified by the user. + */ + if (javaVM->internalVMFunctions->isCRaCorCRIUSupportEnabled(javaVM)) { + const double scaleFactor = 2; + if (!_extensions->dnssExpectedRatioMaximum._wasSpecified && + !_extensions->dnssExpectedRatioMinimum._wasSpecified) { + _extensions->dnssExpectedRatioMaximum._valueSpecified *= scaleFactor; + _extensions->dnssExpectedRatioMinimum._valueSpecified *= scaleFactor; + } + } +#endif /* defined(J9VM_OPT_CRIU_SUPPORT) */ + return true; }