From c58b321c022b8b0e02baebb9cc3229cfa9f2cd91 Mon Sep 17 00:00:00 2001 From: Marius Pirvu Date: Wed, 22 Jan 2025 18:25:17 -0500 Subject: [PATCH] Adjust inliner use of profiled fanin data 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 --- .../compiler/optimizer/InlinerTempForJ9.cpp | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/runtime/compiler/optimizer/InlinerTempForJ9.cpp b/runtime/compiler/optimizer/InlinerTempForJ9.cpp index c508b7c45a9..d5187b6d8e7 100644 --- a/runtime/compiler/optimizer/InlinerTempForJ9.cpp +++ b/runtime/compiler/optimizer/InlinerTempForJ9.cpp @@ -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; + } } } }