Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to enforce/disable IProfiler during startup phase #18381

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions runtime/compiler/control/J9Options.cpp
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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