Skip to content

Commit

Permalink
Adjust inliner use of profiled fanin data
Browse files Browse the repository at this point in the history
The inliner uses some heuristics that tries to avoid the
inlining of large callees that have already been compiled.
What constitutes a large method is determined in a
routine called `isLargeCompileMethod()`.
If the callee is in a large frequency block, then we always
want to inline that callee.
If the callee is in a medium or low frequency block, then we
look at callee size and at the fanin info (how many methods
call this callee). For low frequency blocks we are more
conservative with inlining than with medium frequency blocks.
The existing code contained a bug in that, if there was no fanin
info for a callee in a low/medium frequency block, we would always
inline the callee, regardless of its size.
This commit fixes this problem and considers the size of the callee
first and then the fanin info. If there is no fanin info, then
the size of the callee is the only criterion.

Signed-off-by: Marius Pirvu <[email protected]>
  • Loading branch information
mpirvu committed Jan 24, 2025
1 parent 18777d2 commit c58b321
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions runtime/compiler/optimizer/InlinerTempForJ9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4722,13 +4722,22 @@ bool TR_MultipleCallTargetInliner::isLargeCompiledMethod(TR_ResolvedMethod *call
veryLargeCompiledMethodFaninThreshold = 0;
}
}

uint32_t numCallers = 0, totalWeight = 0;
((TR_ResolvedJ9Method *) calleeResolvedMethod)->getFaninInfo(&numCallers, &totalWeight);
if ((numCallers > veryLargeCompiledMethodFaninThreshold) &&
(bytecodeSize > veryLargeCompiledMethodThreshold))
// Prevent inlining of "large" methods with "many" callers
if (bytecodeSize > veryLargeCompiledMethodThreshold)
{
return true;
uint32_t numCallers = 0, totalWeight = 0;
if (!comp()->getOption(TR_DisableInlinerFanIn))
((TR_ResolvedJ9Method *) calleeResolvedMethod)->getFaninInfo(&numCallers, &totalWeight);
if (numCallers == 0) // no fanin info
{
// If there is no fanin info, prevent inlining just based on method size
return true;
}
else
{
if (numCallers > veryLargeCompiledMethodFaninThreshold)
return true;
}
}
}
}
Expand Down

0 comments on commit c58b321

Please sign in to comment.