Skip to content

Commit

Permalink
Add ability to sleep before checkpoint
Browse files Browse the repository at this point in the history
This commit adds the ability to sleep before a checkpoint to allow the
compilation threads to compile the methods already present in the
compilation queue. It is important that the hook thread releases both
VM Access and the Compilation Monitor before sleeping; otherwise, the
compilation threads will not be able to empty the queue.

Signed-off-by: Irwin D'Souza <dsouzai.gh@gmail.com>
  • Loading branch information
dsouzai committed Aug 29, 2022
1 parent c14fe74 commit fddac4d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions runtime/compiler/control/CompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2646,9 +2646,23 @@ void TR::CompilationInfo::prepareForCheckpoint()
J9JavaVM *vm = _jitConfig->javaVM;
J9VMThread *vmThread = vm->internalVMFunctions->currentVMThread(vm);

if (TR::Options::getCmdLineOptions()->getVerboseOption(TR_VerboseCheckpointRestore))
TR_VerboseLog::writeLineLocked(TR_Vlog_CHECKPOINT_RESTORE, "Preparing for checkpoint");

{
ReleaseVMAccessAndAcquireMonitor suspendCompThreadsForCheckpoint(vmThread, getCompilationMonitor());

if (TR::Options::_sleepMsBeforeCheckpoint)
{
if (TR::Options::getCmdLineOptions()->getVerboseOption(TR_VerboseCheckpointRestore))
TR_VerboseLog::writeLineLocked(TR_Vlog_CHECKPOINT_RESTORE, "Sleeping for %d ms", TR::Options::_sleepMsBeforeCheckpoint);

releaseCompMonitor(vmThread);
j9thread_sleep(static_cast<int64_t>(TR::Options::_sleepMsBeforeCheckpoint));
acquireCompMonitor(vmThread);
}


if (shouldCheckpointBeInterrupted())
return;

Expand Down Expand Up @@ -2713,10 +2727,14 @@ void TR::CompilationInfo::prepareForCheckpoint()
}
}

if (TR::Options::getCmdLineOptions()->getVerboseOption(TR_VerboseCheckpointRestore))
TR_VerboseLog::writeLineLocked(TR_Vlog_CHECKPOINT_RESTORE, "Ready for checkpoint");
}

void TR::CompilationInfo::prepareForRestore()
{
if (TR::Options::getCmdLineOptions()->getVerboseOption(TR_VerboseCheckpointRestore))
TR_VerboseLog::writeLineLocked(TR_Vlog_CHECKPOINT_RESTORE, "Preparing for restore");

{
OMR::CriticalSection resumeCompThreadsForRestore(getCompilationMonitor());
Expand All @@ -2728,6 +2746,8 @@ void TR::CompilationInfo::prepareForRestore()
resumeCompilationThread();
}

if (TR::Options::getCmdLineOptions()->getVerboseOption(TR_VerboseCheckpointRestore))
TR_VerboseLog::writeLineLocked(TR_Vlog_CHECKPOINT_RESTORE, "Ready for restore");
}
#endif // #if defined(J9VM_OPT_CRIU_SUPPORT)

Expand Down
8 changes: 8 additions & 0 deletions runtime/compiler/control/J9Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ int32_t J9::Options::_highActiveThreadThreshold = -1;
int32_t J9::Options::_veryHighActiveThreadThreshold = -1;
#endif /* defined(J9VM_OPT_JITSERVER) */

#if defined(J9VM_OPT_CRIU_SUPPORT)
int32_t J9::Options::_sleepMsBeforeCheckpoint = 1000; // 1 second
#endif

int32_t J9::Options::_interpreterSamplingThreshold = 300;
int32_t J9::Options::_interpreterSamplingDivisor = TR_DEFAULT_INTERPRETER_SAMPLING_DIVISOR;
int32_t J9::Options::_interpreterSamplingThresholdInStartupMode = TR_DEFAULT_INITIAL_BCOUNT; // 3000
Expand Down Expand Up @@ -991,6 +995,10 @@ TR::OptionTable OMR::Options::_feOptions[] = {
TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_sharedROMClassCacheNumPartitions, 0, "F%d", NOT_IN_SUBSET},
#endif /* defined(J9VM_OPT_JITSERVER) */
{"singleCache", "C\tallow only one code cache and one data cache to be allocated", RESET_JITCONFIG_RUNTIME_FLAG(J9JIT_GROW_CACHES) },
#if defined(J9VM_OPT_CRIU_SUPPORT)
{"sleepMsBeforeCheckpoint=", " O<nnn>\tNumber of milliseconds to sleep before a checkpoint",
TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_sleepMsBeforeCheckpoint, 0, "F%d" },
#endif
{"smallMethodBytecodeSizeThreshold=", "O<nnn> \tThreshold for determining small methods "
"(measured in number of bytecodes)",
TR::Options::setStaticNumeric, (intptr_t)&TR::Options::_smallMethodBytecodeSizeThreshold, 0, "F%d", NOT_IN_SUBSET},
Expand Down
4 changes: 4 additions & 0 deletions runtime/compiler/control/J9Options.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ class OMR_EXTENSIBLE Options : public OMR::OptionsConnector
static const uint32_t DEFAULT_JITSERVER_TIMEOUT = 30000; // ms
#endif /* defined(J9VM_OPT_JITSERVER) */

#if defined(J9VM_OPT_CRIU_SUPPORT)
static int32_t _sleepMsBeforeCheckpoint;
#endif

static int32_t _waitTimeToEnterIdleMode;
static int32_t _waitTimeToEnterDeepIdleMode;
static int32_t _waitTimeToExitStartupMode;
Expand Down

0 comments on commit fddac4d

Please sign in to comment.