Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

JIT: expose inline budget as a jit config option #114103

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -11410,10 +11410,12 @@ class Compiler

#define DEFAULT_MAX_INLINE_SIZE \
100 // Methods with > DEFAULT_MAX_INLINE_SIZE IL bytes will never be inlined.
// This can be overwritten by setting DOTNET_JITInlineSize env variable.
// This can be overwritten by setting DOTNET_JitInlineSize env variable.

#define DEFAULT_MAX_INLINE_DEPTH 20 // Methods at more than this level deep will not be inlined

#define DEFAULT_INLINE_BUDGET 10 // Maximum estimated compile time increase via inlining

#define DEFAULT_MAX_FORCE_INLINE_DEPTH 1 // Methods at more than this level deep will not be force inlined

#define DEFAULT_MAX_LOCALLOC_TO_LOCAL_SIZE 32 // fixed locallocs of this size or smaller will convert to local buffers
Expand Down
9 changes: 8 additions & 1 deletion src/coreclr/jit/inline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,14 @@ InlineContext* InlineStrategy::GetRootContext()
// Set the initial budget for inlining. Note this is
// deliberately set very high and is intended to catch
// only pathological runaway inline cases.
m_InitialTimeBudget = BUDGET * m_InitialTimeEstimate;
const unsigned budget = JitConfig.JitInlineBudget();

if (budget != DEFAULT_INLINE_BUDGET)
{
JITDUMP("Using non-default inline budget %u\n", budget);
}

m_InitialTimeBudget = budget * m_InitialTimeEstimate;
m_CurrentTimeBudget = m_InitialTimeBudget;

// Estimate the code size if there's no inlining
Expand Down
8 changes: 0 additions & 8 deletions src/coreclr/jit/inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -1073,14 +1073,6 @@ class InlineStrategy
// Accounting updates for a successful or failed inline.
void NoteOutcome(InlineContext* context);

// Cap on allowable increase in jit time due to inlining.
// Multiplicative, so BUDGET = 10 means up to 10x increase
// in jit time.
enum
{
BUDGET = 10
};

// Estimate the jit time change because of this inline.
int EstimateTime(InlineContext* context);

Expand Down
7 changes: 4 additions & 3 deletions src/coreclr/jit/jitconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ CONFIG_INTEGER(JitHashBreak, "JitHashBreak", -1) // Same as JitBreak, but
CONFIG_INTEGER(JitHashHalt, "JitHashHalt", -1) // Same as JitHalt, but for a method hash
CONFIG_INTEGER(JitInlineAdditionalMultiplier, "JitInlineAdditionalMultiplier", 0)
CONFIG_INTEGER(JitInlinePrintStats, "JitInlinePrintStats", 0)
CONFIG_INTEGER(JitInlineSize, "JITInlineSize", DEFAULT_MAX_INLINE_SIZE)
CONFIG_INTEGER(JitInlineDepth, "JITInlineDepth", DEFAULT_MAX_INLINE_DEPTH)
CONFIG_INTEGER(JitForceInlineDepth, "JITForceInlineDepth", DEFAULT_MAX_FORCE_INLINE_DEPTH)
CONFIG_INTEGER(JitInlineSize, "JitInlineSize", DEFAULT_MAX_INLINE_SIZE)
CONFIG_INTEGER(JitInlineDepth, "JitInlineDepth", DEFAULT_MAX_INLINE_DEPTH)
RELEASE_CONFIG_INTEGER(JitInlineBudget, "JitInlineBudget", DEFAULT_INLINE_BUDGET)
CONFIG_INTEGER(JitForceInlineDepth, "JitForceInlineDepth", DEFAULT_MAX_FORCE_INLINE_DEPTH)
RELEASE_CONFIG_INTEGER(JitInlineMethodsWithEH, "JitInlineMethodsWithEH", 1)
CONFIG_STRING(JitInlineMethodsWithEHRange, "JitInlineMethodsWithEHRange")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Compile Include="$(MSBuildProjectName).cs" />

<CLRTestEnvironmentVariable Include="DOTNET_EnableHWIntrinsic" Value="0" />
<CLRTestEnvironmentVariable Include="DOTNET_JITInlineDepth" Value="0" />
<CLRTestEnvironmentVariable Include="DOTNET_JitInlineDepth" Value="0" />
<CLRTestEnvironmentVariable Include="DOTNET_TieredCompilation" Value="0" />
</ItemGroup>
</Project>
Loading