From a73ea43f7ce773a4a3f3954324ed8828965117ba Mon Sep 17 00:00:00 2001 From: Marius Pirvu Date: Fri, 18 Feb 2022 10:33:10 -0500 Subject: [PATCH] Allow more expensive hot compilations under -Xtune:throughput This commit enables two changes for hot/scorching compilations performed under the -Xtune:throughput mode: 1. -Xjit:acceptHugeMethod is enabled, allowing more complex methods to be successfuly compiled. This change can be disabled by setting the following environment variable: TR_DontAcceptHugeMethods=1 2. The JIT scratch memory limit is increased from 256 MB to 512 MB allowing compilations that need more memory to succeed. The new scratch memory limit value for hot compilations can be controlled with -Xjit:scratchSpaceLimitKBForHotCompilations= Signed-off-by: Marius Pirvu --- runtime/compiler/control/CompilationThread.cpp | 18 ++++++++++++++++++ runtime/compiler/control/J9Options.cpp | 3 +++ runtime/compiler/control/J9Options.hpp | 3 +++ 3 files changed, 24 insertions(+) diff --git a/runtime/compiler/control/CompilationThread.cpp b/runtime/compiler/control/CompilationThread.cpp index 93447d35d9c..42b6a9e1f79 100644 --- a/runtime/compiler/control/CompilationThread.cpp +++ b/runtime/compiler/control/CompilationThread.cpp @@ -8559,6 +8559,17 @@ TR::CompilationInfoPerThreadBase::wrappedCompile(J9PortLibrary *portLib, void * TR_ASSERT(TR::comp() == NULL, "there seems to be a current TLS TR::Compilation object %p for this thread. At this point there should be no current TR::Compilation object", TR::comp()); + // Under -Xtune:throughput we allow huge methods for compilations above warm + if (TR::Options::getAggressivityLevel() == TR::Options::TR_AggresivenessLevel::AGGRESSIVE_THROUGHPUT && + options->getOptLevel() > warm && + !options->getOption(TR_ProcessHugeMethods)) + { + static char *dontAcceptHugeMethods = feGetEnv("TR_DontAcceptHugeMethods"); + if (!dontAcceptHugeMethods) + { + options->setOption(TR_ProcessHugeMethods); + } + } } uint64_t proposedScratchMemoryLimit = static_cast(TR::Options::getScratchSpaceLimit()); @@ -8722,6 +8733,13 @@ TR::CompilationInfoPerThreadBase::wrappedCompile(J9PortLibrary *portLib, void * compiler->getOptions()->setBigCalleeScorchingOptThreshold(1024); #endif } + // Under -Xtune:throughput, increase the scratch space limit for hot/scorching compilations + else if (TR::Options::getAggressivityLevel() == TR::Options::TR_AggresivenessLevel::AGGRESSIVE_THROUGHPUT && + compiler->getOptions()->getOptLevel() > warm && + TR::Options::getScratchSpaceLimitForHotCompilations() > proposedScratchMemoryLimit) // Make sure we don't decrease the value proposed so far + { + proposedScratchMemoryLimit = TR::Options::getScratchSpaceLimitForHotCompilations(); + } #if defined(J9VM_OPT_JITSERVER) else if (compiler->isOutOfProcessCompilation()) { diff --git a/runtime/compiler/control/J9Options.cpp b/runtime/compiler/control/J9Options.cpp index af9faa8e4dd..e6c4656f485 100644 --- a/runtime/compiler/control/J9Options.cpp +++ b/runtime/compiler/control/J9Options.cpp @@ -265,6 +265,7 @@ int32_t J9::Options::_updateFreeMemoryMinPeriod = 500; // 500 ms size_t J9::Options::_scratchSpaceLimitKBWhenLowVirtualMemory = 64*1024; // 64MB; currently, only used on 32 bit Windows int32_t J9::Options::_scratchSpaceFactorWhenJSR292Workload = JSR292_SCRATCH_SPACE_FACTOR; +size_t J9::Options::_scratchSpaceLimitForHotCompilations = 512 * 1024 * 1024; // 512 MB #if defined(J9VM_OPT_JITSERVER) int32_t J9::Options::_scratchSpaceFactorWhenJITServerWorkload = 2; #endif /* defined(J9VM_OPT_JITSERVER) */ @@ -977,6 +978,8 @@ TR::OptionTable OMR::Options::_feOptions[] = { #endif /* defined(J9VM_OPT_JITSERVER) */ {"scratchSpaceFactorWhenJSR292Workload=","M\tMultiplier for scratch space limit when MethodHandles are in use", TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_scratchSpaceFactorWhenJSR292Workload, 0, "F%d", NOT_IN_SUBSET}, + {"scratchSpaceLimitKBForHotCompilations=","M\tLimit for memory used by JIT when compiling at hot and above (in KB)", + TR::Options::setStaticNumericKBAdjusted, (intptr_t)&TR::Options::_scratchSpaceLimitForHotCompilations, 0, "F%d (bytes)", NOT_IN_SUBSET}, {"scratchSpaceLimitKBWhenLowVirtualMemory=","M\tLimit for memory used by JIT when running on low virtual memory", TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_scratchSpaceLimitKBWhenLowVirtualMemory, 0, "F%d", NOT_IN_SUBSET}, {"secondaryClassLoadPhaseThreshold=", "O\tWhen class load rate just dropped under the CLP threshold " diff --git a/runtime/compiler/control/J9Options.hpp b/runtime/compiler/control/J9Options.hpp index 7bc28a52872..b7c651470b7 100644 --- a/runtime/compiler/control/J9Options.hpp +++ b/runtime/compiler/control/J9Options.hpp @@ -221,6 +221,9 @@ class OMR_EXTENSIBLE Options : public OMR::OptionsConnector static int32_t _scratchSpaceFactorWhenJSR292Workload; static int32_t getScratchSpaceFactorWhenJSR292Workload() { return _scratchSpaceFactorWhenJSR292Workload; } + static size_t _scratchSpaceLimitForHotCompilations; // Only used under -Xtune:throughput + static size_t getScratchSpaceLimitForHotCompilations() { return _scratchSpaceLimitForHotCompilations; } + #if defined(J9VM_OPT_JITSERVER) static int32_t _scratchSpaceFactorWhenJITServerWorkload; static int32_t getScratchSpaceFactorWhenJITServerWorkload() { return _scratchSpaceFactorWhenJITServerWorkload; }