Skip to content

Commit

Permalink
Merge pull request #18381 from rmnattas/alwaysProfileXXOption
Browse files Browse the repository at this point in the history
Add option to enforce/disable IProfiler during startup phase
  • Loading branch information
mpirvu committed Nov 3, 2023
2 parents 6378d21 + a92489d commit b614f6c
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 14 deletions.
39 changes: 27 additions & 12 deletions runtime/compiler/control/J9Options.cpp
Expand Up @@ -375,7 +375,9 @@ char * J9::Options::_externalOptionStrings[J9::ExternalOptions::TR_NumExternalOp
"-XX:codecachetotalMaxRAMPercentage=", // = 67
"-XX:+JITServerAOTCacheDelayMethodRelocation", // = 68
"-XX:-JITServerAOTCacheDelayMethodRelocation", // = 69
// TR_NumExternalOptions = 70
"-XX:+IProfileDuringStartupPhase", // = 70
"-XX:-IProfileDuringStartupPhase", // = 71
// TR_NumExternalOptions = 72
};

//************************************************************************
Expand Down Expand Up @@ -3142,25 +3144,38 @@ bool J9::Options::feLatePostProcess(void * base, TR::OptionSet * optionSet)
}
else // do AOT
{
if (!self()->getOption(TR_DisablePersistIProfile))
// Turn off Iprofiler for the warm runs, but not if we cache only bootstrap classes
// This is because we may be missing IProfiler information for non-bootstrap classes
// that could not be stored in SCC
if (!self()->getOption(TR_DisablePersistIProfile) &&
J9_ARE_ALL_BITS_SET(javaVM->sharedClassConfig->runtimeFlags, J9SHR_RUNTIMEFLAG_ENABLE_CACHE_NON_BOOT_CLASSES))
{
// Turn off Iprofiler for the warm runs, but not if we cache only bootstrap classes
// This is because we may be missing IProfiler information for non-bootstrap classes
// that could not be stored in SCC
if (J9_ARE_ALL_BITS_SET(javaVM->sharedClassConfig->runtimeFlags, J9SHR_RUNTIMEFLAG_ENABLE_CACHE_NON_BOOT_CLASSES))
TR::CompilationInfo * compInfo = getCompilationInfo(jitConfig);
if (compInfo->isWarmSCC() == TR_yes)
{
TR::CompilationInfo * compInfo = getCompilationInfo(jitConfig);
static char * dnipdsp = feGetEnv("TR_DisableNoIProfilerDuringStartupPhase");
if (compInfo->isWarmSCC() == TR_yes && !dnipdsp)
{
self()->setOption(TR_NoIProfilerDuringStartupPhase);
}
self()->setOption(TR_NoIProfilerDuringStartupPhase);
}
}
}
}
#endif

// The use of -XX:[+/-]IProfileDuringStartupPhase sets if we always/never IProfile
// during the startup phase
{
// The FIND_ARG_IN_VMARGS macro expect the J9JavaVM to be in the `vm` variable, instead of `javaVM`
// The method uses the `vm` variable for the TR_J9VMBase
J9JavaVM * vm = javaVM;
const char *xxIProfileDuringStartupPhase = J9::Options::_externalOptionStrings[J9::ExternalOptions::XXplusIProfileDuringStartupPhase];
const char *xxDisableIProfileDuringStartupPhase = J9::Options::_externalOptionStrings[J9::ExternalOptions::XXminusIProfileDuringStartupPhase];
int32_t xxIProfileDuringStartupPhaseArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxIProfileDuringStartupPhase, 0);
int32_t xxDisableIProfileDuringStartupPhaseArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxDisableIProfileDuringStartupPhase, 0);
if (xxIProfileDuringStartupPhaseArgIndex > xxDisableIProfileDuringStartupPhaseArgIndex)
self()->setOption(TR_NoIProfilerDuringStartupPhase, false); // Override -Xjit:noIProfilerDuringStartupPhase
else if (xxDisableIProfileDuringStartupPhaseArgIndex >= 0)
self()->setOption(TR_NoIProfilerDuringStartupPhase);
}

// Divide by 0 checks
if (TR::Options::_LoopyMethodDivisionFactor == 0)
TR::Options::_LoopyMethodDivisionFactor = 16; // Reset it back to the default value
Expand Down
4 changes: 3 additions & 1 deletion runtime/compiler/control/J9Options.hpp
Expand Up @@ -123,7 +123,9 @@ enum ExternalOptions
XXcodecachetotalMaxRAMPercentage = 67,
XXplusJITServerAOTCacheDelayMethodRelocation = 68,
XXminusJITServerAOTCacheDelayMethodRelocation = 69,
TR_NumExternalOptions = 70
XXplusIProfileDuringStartupPhase = 70,
XXminusIProfileDuringStartupPhase = 71,
TR_NumExternalOptions = 72
};

class OMR_EXTENSIBLE Options : public OMR::OptionsConnector
Expand Down
36 changes: 35 additions & 1 deletion runtime/compiler/control/OptionsPostRestore.cpp
Expand Up @@ -78,7 +78,9 @@ J9::OptionsPostRestore::OptionsPostRestore(J9VMThread *vmThread, J9JITConfig *ji
_argIndexUseJITServer(-1),
_argIndexDisableUseJITServer(-1),
_argIndexJITServerAddress(-1),
_argIndexJITServerAOTCacheName(-1)
_argIndexJITServerAOTCacheName(-1),
_argIndexIProfileDuringStartupPhase(-1),
_argIndexDisableIProfileDuringStartupPhase(-1)
{
J9JavaVM *vm = jitConfig->javaVM;
if (vm->sharedClassConfig)
Expand Down Expand Up @@ -276,6 +278,18 @@ J9::OptionsPostRestore::iterateOverExternalOptions()
}
break;

case J9::ExternalOptions::XXplusIProfileDuringStartupPhase:
{
_argIndexIProfileDuringStartupPhase = FIND_ARG_IN_RESTORE_ARGS(EXACT_MATCH, optString, 0);
}
break;

case J9::ExternalOptions::XXminusIProfileDuringStartupPhase:
{
_argIndexDisableIProfileDuringStartupPhase = FIND_ARG_IN_RESTORE_ARGS(EXACT_MATCH, optString, 0);
}
break;

default:
TR_ASSERT_FATAL(false, "Option %s not addressed post restore\n", TR::Options::_externalOptionStrings[option]);
}
Expand Down Expand Up @@ -713,6 +727,26 @@ J9::OptionsPostRestore::postProcessInternalCompilerOptions()
if (TR::Options::getCmdLineOptions()->getOption(TR_DisableAsyncCompilation))
TR::Options::getCmdLineOptions()->setOption(TR_DisableAsyncCompilation, false);
}

// Set/Reset TR_NoIProfilerDuringStartupPhase if -XX:[+/-]IProfileDuringStartupPhase is used
// Otherwise use the default logic to determine if TR_NoIProfilerDuringStartupPhase is set
if ((_argIndexIProfileDuringStartupPhase >= 0) || (_argIndexDisableIProfileDuringStartupPhase >= 0))
{
bool IProfileDuringStartupPhase = (_argIndexIProfileDuringStartupPhase > _argIndexDisableIProfileDuringStartupPhase);
TR::Options::getCmdLineOptions()->setOption(TR_NoIProfilerDuringStartupPhase, !IProfileDuringStartupPhase);
}
else if (!disableAOT)
{
if (!TR::Options::getCmdLineOptions()->getOption(TR_DisablePersistIProfile) &&
J9_ARE_ALL_BITS_SET(vm->sharedClassConfig->runtimeFlags, J9SHR_RUNTIMEFLAG_ENABLE_CACHE_NON_BOOT_CLASSES))
{
if (_compInfo->isWarmSCC() == TR_yes)
{
TR::Options::getCmdLineOptions()->setOption(TR_NoIProfilerDuringStartupPhase);
}
}
}

}

void
Expand Down
2 changes: 2 additions & 0 deletions runtime/compiler/control/OptionsPostRestore.hpp
Expand Up @@ -183,6 +183,8 @@ class OptionsPostRestore
int32_t _argIndexDisableUseJITServer;
int32_t _argIndexJITServerAddress;
int32_t _argIndexJITServerAOTCacheName;
int32_t _argIndexIProfileDuringStartupPhase;
int32_t _argIndexDisableIProfileDuringStartupPhase;
};

}
Expand Down

0 comments on commit b614f6c

Please sign in to comment.