Skip to content

Commit a92489d

Browse files
committed
Add new -XX option to enforce/disable IProfiler during startup phase
New option: `-XX:[+/-]IProfileDuringStartupPhase` Overrides `-Xjit:noIProfilerDuringStartupPhase` Imitate the behaviour for CRIU restore Signed-off-by: Abdulrahman Alattas <rmnattas@gmail.com>
1 parent 06c3abc commit a92489d

File tree

4 files changed

+67
-14
lines changed

4 files changed

+67
-14
lines changed

runtime/compiler/control/J9Options.cpp

+27-12
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,9 @@ char * J9::Options::_externalOptionStrings[J9::ExternalOptions::TR_NumExternalOp
375375
"-XX:codecachetotalMaxRAMPercentage=", // = 67
376376
"-XX:+JITServerAOTCacheDelayMethodRelocation", // = 68
377377
"-XX:-JITServerAOTCacheDelayMethodRelocation", // = 69
378-
// TR_NumExternalOptions = 70
378+
"-XX:+IProfileDuringStartupPhase", // = 70
379+
"-XX:-IProfileDuringStartupPhase", // = 71
380+
// TR_NumExternalOptions = 72
379381
};
380382

381383
//************************************************************************
@@ -3142,25 +3144,38 @@ bool J9::Options::feLatePostProcess(void * base, TR::OptionSet * optionSet)
31423144
}
31433145
else // do AOT
31443146
{
3145-
if (!self()->getOption(TR_DisablePersistIProfile))
3147+
// Turn off Iprofiler for the warm runs, but not if we cache only bootstrap classes
3148+
// This is because we may be missing IProfiler information for non-bootstrap classes
3149+
// that could not be stored in SCC
3150+
if (!self()->getOption(TR_DisablePersistIProfile) &&
3151+
J9_ARE_ALL_BITS_SET(javaVM->sharedClassConfig->runtimeFlags, J9SHR_RUNTIMEFLAG_ENABLE_CACHE_NON_BOOT_CLASSES))
31463152
{
3147-
// Turn off Iprofiler for the warm runs, but not if we cache only bootstrap classes
3148-
// This is because we may be missing IProfiler information for non-bootstrap classes
3149-
// that could not be stored in SCC
3150-
if (J9_ARE_ALL_BITS_SET(javaVM->sharedClassConfig->runtimeFlags, J9SHR_RUNTIMEFLAG_ENABLE_CACHE_NON_BOOT_CLASSES))
3153+
TR::CompilationInfo * compInfo = getCompilationInfo(jitConfig);
3154+
if (compInfo->isWarmSCC() == TR_yes)
31513155
{
3152-
TR::CompilationInfo * compInfo = getCompilationInfo(jitConfig);
3153-
static char * dnipdsp = feGetEnv("TR_DisableNoIProfilerDuringStartupPhase");
3154-
if (compInfo->isWarmSCC() == TR_yes && !dnipdsp)
3155-
{
3156-
self()->setOption(TR_NoIProfilerDuringStartupPhase);
3157-
}
3156+
self()->setOption(TR_NoIProfilerDuringStartupPhase);
31583157
}
31593158
}
31603159
}
31613160
}
31623161
#endif
31633162

3163+
// The use of -XX:[+/-]IProfileDuringStartupPhase sets if we always/never IProfile
3164+
// during the startup phase
3165+
{
3166+
// The FIND_ARG_IN_VMARGS macro expect the J9JavaVM to be in the `vm` variable, instead of `javaVM`
3167+
// The method uses the `vm` variable for the TR_J9VMBase
3168+
J9JavaVM * vm = javaVM;
3169+
const char *xxIProfileDuringStartupPhase = J9::Options::_externalOptionStrings[J9::ExternalOptions::XXplusIProfileDuringStartupPhase];
3170+
const char *xxDisableIProfileDuringStartupPhase = J9::Options::_externalOptionStrings[J9::ExternalOptions::XXminusIProfileDuringStartupPhase];
3171+
int32_t xxIProfileDuringStartupPhaseArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxIProfileDuringStartupPhase, 0);
3172+
int32_t xxDisableIProfileDuringStartupPhaseArgIndex = FIND_ARG_IN_VMARGS(EXACT_MATCH, xxDisableIProfileDuringStartupPhase, 0);
3173+
if (xxIProfileDuringStartupPhaseArgIndex > xxDisableIProfileDuringStartupPhaseArgIndex)
3174+
self()->setOption(TR_NoIProfilerDuringStartupPhase, false); // Override -Xjit:noIProfilerDuringStartupPhase
3175+
else if (xxDisableIProfileDuringStartupPhaseArgIndex >= 0)
3176+
self()->setOption(TR_NoIProfilerDuringStartupPhase);
3177+
}
3178+
31643179
// Divide by 0 checks
31653180
if (TR::Options::_LoopyMethodDivisionFactor == 0)
31663181
TR::Options::_LoopyMethodDivisionFactor = 16; // Reset it back to the default value

runtime/compiler/control/J9Options.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ enum ExternalOptions
123123
XXcodecachetotalMaxRAMPercentage = 67,
124124
XXplusJITServerAOTCacheDelayMethodRelocation = 68,
125125
XXminusJITServerAOTCacheDelayMethodRelocation = 69,
126-
TR_NumExternalOptions = 70
126+
XXplusIProfileDuringStartupPhase = 70,
127+
XXminusIProfileDuringStartupPhase = 71,
128+
TR_NumExternalOptions = 72
127129
};
128130

129131
class OMR_EXTENSIBLE Options : public OMR::OptionsConnector

runtime/compiler/control/OptionsPostRestore.cpp

+35-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ J9::OptionsPostRestore::OptionsPostRestore(J9VMThread *vmThread, J9JITConfig *ji
7878
_argIndexUseJITServer(-1),
7979
_argIndexDisableUseJITServer(-1),
8080
_argIndexJITServerAddress(-1),
81-
_argIndexJITServerAOTCacheName(-1)
81+
_argIndexJITServerAOTCacheName(-1),
82+
_argIndexIProfileDuringStartupPhase(-1),
83+
_argIndexDisableIProfileDuringStartupPhase(-1)
8284
{
8385
J9JavaVM *vm = jitConfig->javaVM;
8486
if (vm->sharedClassConfig)
@@ -276,6 +278,18 @@ J9::OptionsPostRestore::iterateOverExternalOptions()
276278
}
277279
break;
278280

281+
case J9::ExternalOptions::XXplusIProfileDuringStartupPhase:
282+
{
283+
_argIndexIProfileDuringStartupPhase = FIND_ARG_IN_RESTORE_ARGS(EXACT_MATCH, optString, 0);
284+
}
285+
break;
286+
287+
case J9::ExternalOptions::XXminusIProfileDuringStartupPhase:
288+
{
289+
_argIndexDisableIProfileDuringStartupPhase = FIND_ARG_IN_RESTORE_ARGS(EXACT_MATCH, optString, 0);
290+
}
291+
break;
292+
279293
default:
280294
TR_ASSERT_FATAL(false, "Option %s not addressed post restore\n", TR::Options::_externalOptionStrings[option]);
281295
}
@@ -713,6 +727,26 @@ J9::OptionsPostRestore::postProcessInternalCompilerOptions()
713727
if (TR::Options::getCmdLineOptions()->getOption(TR_DisableAsyncCompilation))
714728
TR::Options::getCmdLineOptions()->setOption(TR_DisableAsyncCompilation, false);
715729
}
730+
731+
// Set/Reset TR_NoIProfilerDuringStartupPhase if -XX:[+/-]IProfileDuringStartupPhase is used
732+
// Otherwise use the default logic to determine if TR_NoIProfilerDuringStartupPhase is set
733+
if ((_argIndexIProfileDuringStartupPhase >= 0) || (_argIndexDisableIProfileDuringStartupPhase >= 0))
734+
{
735+
bool IProfileDuringStartupPhase = (_argIndexIProfileDuringStartupPhase > _argIndexDisableIProfileDuringStartupPhase);
736+
TR::Options::getCmdLineOptions()->setOption(TR_NoIProfilerDuringStartupPhase, !IProfileDuringStartupPhase);
737+
}
738+
else if (!disableAOT)
739+
{
740+
if (!TR::Options::getCmdLineOptions()->getOption(TR_DisablePersistIProfile) &&
741+
J9_ARE_ALL_BITS_SET(vm->sharedClassConfig->runtimeFlags, J9SHR_RUNTIMEFLAG_ENABLE_CACHE_NON_BOOT_CLASSES))
742+
{
743+
if (_compInfo->isWarmSCC() == TR_yes)
744+
{
745+
TR::Options::getCmdLineOptions()->setOption(TR_NoIProfilerDuringStartupPhase);
746+
}
747+
}
748+
}
749+
716750
}
717751

718752
void

runtime/compiler/control/OptionsPostRestore.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,8 @@ class OptionsPostRestore
183183
int32_t _argIndexDisableUseJITServer;
184184
int32_t _argIndexJITServerAddress;
185185
int32_t _argIndexJITServerAOTCacheName;
186+
int32_t _argIndexIProfileDuringStartupPhase;
187+
int32_t _argIndexDisableIProfileDuringStartupPhase;
186188
};
187189

188190
}

0 commit comments

Comments
 (0)