Skip to content

Commit

Permalink
Merge pull request #3139 from mpirvu/newactivpolicy
Browse files Browse the repository at this point in the history
Change heuristics for activating compilation threads
  • Loading branch information
ymanton authored Oct 5, 2018
2 parents 856d92e + c7c2da3 commit 1b800b0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
17 changes: 9 additions & 8 deletions runtime/compiler/control/CompilationThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,22 +388,23 @@ TR_YesNoMaybe TR::CompilationInfo::shouldActivateNewCompThread()
// determined based on the number of CPUs, then the upper bound of comp threads is _numTargetCPUs-1
// However, if the compilation threads are starved (on Linux) we may want
// to activate additional comp threads irrespective of the CPU entitlement
if (TR::Options::_useCPUsToDetermineMaxNumberOfCompThreadsToActivate ||
!_starvationDetected)
if (TR::Options::_useCPUsToDetermineMaxNumberOfCompThreadsToActivate)
{
if (getNumCompThreadsActive() >= getNumTargetCPUs() - 1)
if (getNumCompThreadsActive() < getNumTargetCPUs() - 1)
{
return TR_no;
if (_queueWeight > compThreadActivationThresholds[getNumCompThreadsActive()])
return TR_yes;
}
else
else if (_starvationDetected)
{
if (_queueWeight > compThreadActivationThresholds[getNumCompThreadsActive()])
// comp thread starvation; may activate threads beyond numCpu-1
if (_queueWeight > compThreadActivationThresholdsonStarvation[getNumCompThreadsActive()])
return TR_yes;
}
}
else // comp thread starvation; may activate threads beyond numCpu-1
else // number of compilation threads indicated by the user
{
if (_queueWeight > compThreadActivationThresholdsonStarvation[getNumCompThreadsActive()])
if (_queueWeight > compThreadActivationThresholds[getNumCompThreadsActive()])
return TR_yes;
}

Expand Down
19 changes: 10 additions & 9 deletions runtime/compiler/control/J9Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1990,22 +1990,23 @@ J9::Options::fePostProcessJIT(void * base)
//
if (_numUsableCompilationThreads <= 0)
{
#ifdef LINUX
// For linux we may want to create more threads to overcome thread
// starvation due to lack of priorities
//
if (!TR::Options::getCmdLineOptions()->getOption(TR_DisableRampupImprovements) &&
!TR::Options::getAOTCmdLineOptions()->getOption(TR_DisableRampupImprovements))
_numUsableCompilationThreads = MAX_USABLE_COMP_THREADS;
#endif // LINUX
_useCPUsToDetermineMaxNumberOfCompThreadsToActivate = true;
if (TR::Compiler->target.isLinux())
{
// For linux we may want to create more threads to overcome thread
// starvation due to lack of priorities
//
if (!TR::Options::getCmdLineOptions()->getOption(TR_DisableRampupImprovements) &&
!TR::Options::getAOTCmdLineOptions()->getOption(TR_DisableRampupImprovements))
_numUsableCompilationThreads = MAX_USABLE_COMP_THREADS;
}
if (_numUsableCompilationThreads <= 0)
{
// Determine the number of compilation threads based on number of online processors
// Do not create more than numProc-1 compilation threads, but at least one
//
uint32_t numOnlineCPUs = j9sysinfo_get_number_CPUs_by_type(J9PORT_CPU_ONLINE);
_numUsableCompilationThreads = numOnlineCPUs > 1 ? std::min((numOnlineCPUs - 1), static_cast<uint32_t>(MAX_USABLE_COMP_THREADS)) : 1;
_useCPUsToDetermineMaxNumberOfCompThreadsToActivate = true;
}
}

Expand Down

0 comments on commit 1b800b0

Please sign in to comment.