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

Fix missing diagnostics and tuning knobs in inliner #20890

Merged
merged 1 commit into from
Jan 15, 2025
Merged
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
18 changes: 15 additions & 3 deletions runtime/compiler/optimizer/J9EstimateCodeSize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ const float TR_J9EstimateCodeSize::CONST_ARG_IN_CALLEE_ADJUSTMENT_FACTOR = 0.75f

#define DEFAULT_KNOWN_OBJ_WEIGHT 10

#define DEFAULT_FREQ_CUTOFF 40


/*
DEFINEs are ugly in general, but putting
if (tracer)
Expand Down Expand Up @@ -1294,7 +1297,11 @@ TR_J9EstimateCodeSize::realEstimateCodeSize(TR_CallTarget *calltarget, TR_CallSt
return returnCleanup(ECS_VISITED_COUNT_THRESHOLD_EXCEEDED);
}

if (_recursionDepth > MAX_ECS_RECURSION_DEPTH)

static const char *mrd = feGetEnv("TR_MaxRecursionDepth");
static const int32_t maxRecDepth = mrd ? atoi(mrd) : MAX_ECS_RECURSION_DEPTH;

if (_recursionDepth > maxRecDepth)
{
calltarget->_isPartialInliningCandidate = false;
heuristicTrace(tracer(), "*** Depth %d: ECS end for target %p signature %s. Exceeded Recursion Depth", _recursionDepth, calltarget, callerName);
Expand Down Expand Up @@ -1669,7 +1676,9 @@ TR_J9EstimateCodeSize::realEstimateCodeSize(TR_CallTarget *calltarget, TR_CallSt
}
else
{
int32_t freqCutoff = 40;
static const char *fc = feGetEnv("TR_FrequencyCutoff");
static const int32_t freqCutoff = fc ? atoi(fc) : DEFAULT_FREQ_CUTOFF;

bool isColdCall = (((comp()->getMethodHotness() <= warm) && profileManager->isColdCall(targetCallee->_calleeMethod->getPersistentIdentifier(), calltarget->_calleeMethod->getPersistentIdentifier(), i, comp())) || (currentBlock->getFrequency() < freqCutoff)) && !_inliner->alwaysWorthInlining(targetCallee->_calleeMethod, NULL);

if (coldCallInfoIsReliable && isColdCall)
Expand Down Expand Up @@ -1802,6 +1811,7 @@ TR_J9EstimateCodeSize::realEstimateCodeSize(TR_CallTarget *calltarget, TR_CallSt
calltarget->addDeadCallee(callSites[i]);
j--;
_numOfEstimatedCalls--;
heuristicTrace(tracer(),"Depth %d: estimateCodeSize skipping estimated call and resetting _optimisticSize to %d and _realSize to %d", _recursionDepth, _optimisticSize, _realSize);
}

if(comp()->getVisitCount() > HIGH_VISIT_COUNT)
Expand All @@ -1823,6 +1833,8 @@ TR_J9EstimateCodeSize::realEstimateCodeSize(TR_CallTarget *calltarget, TR_CallSt
calltarget->addDeadCallee(callSites[i]);
j--;
_numOfEstimatedCalls--;

heuristicTrace(tracer(),"Depth %d: estimateCodeSize skipping too big estimated call and resetting _optimisticSize to %d and _realSize to %d", _recursionDepth, _optimisticSize, _realSize);
}

if(comp()->getVisitCount() > HIGH_VISIT_COUNT)
Expand All @@ -1836,7 +1848,7 @@ TR_J9EstimateCodeSize::realEstimateCodeSize(TR_CallTarget *calltarget, TR_CallSt
}
else
{
heuristicTrace(tracer(),"Depth %d: estimateCodeSize aborting due to _optimisticSize: %d > sizeThreshold: %d",_optimisticSize,sizeThreshold);
heuristicTrace(tracer(),"Depth %d: estimateCodeSize aborting due to _optimisticSize: %d > sizeThreshold: %d", _recursionDepth, _optimisticSize,sizeThreshold);
break;
}
}
Expand Down