Skip to content

Commit

Permalink
Disable tier 0 JIT (quick JIT) by default, rename config option
Browse files Browse the repository at this point in the history
- Tier 0 JIT is being called quick JIT in config options, renamed DisableTier0Jit to StartupTierQuickJit
- Disabled quick JIT by default, the current plan is to do that for preview 4
  - Concerns were that code produced by quick JIT may be slow, may allocate more, may use more stack space, and may be much larger than optimized code, and there there may be many cases where these things lead to regressions when the span of time between startup and steady-state is important
  - The thought was that with quick JIT disabled, tiering overhead from call counting and backgorund jitting with optimizations would be less, and perf during any point in time would be closer to 2.x releases
  - This mostly loses the startup perf gains from tiering. It may also be slightly slower compared with tiering off due to some overhead. When quick JIT is disabled for the startup tier, made a change to disable tiered compilation for methods in modules that are not R2R'ed since they will not be tiered currently anyway. The overhead and regression in R2R'ed modules will be looked into separately to see if it can be reduced.
- Added config option ForceQuickJit, which uses quick JIT instead of the normal JIT. Off by default. Disables tiering.

Fixes https://github.com/dotnet/coreclr/issues/22998
Fixes https://github.com/dotnet/coreclr/issues/19751
  • Loading branch information
kouvel committed Apr 2, 2019
1 parent c90716a commit a25a565
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 9 deletions.
8 changes: 7 additions & 1 deletion src/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -650,15 +650,21 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_GainExponent,
///
#ifdef FEATURE_TIERED_COMPILATION
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_TieredCompilation, W("TieredCompilation"), 1, "Enables tiered compilation")
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TC_StartupTier_QuickJit, W("TC_StartupTier_QuickJit"), 0, "For methods that would be jitted, enable using quick JIT in the startup tier.")
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_Tier1CallCountThreshold, W("TieredCompilation_Tier1CallCountThreshold"), 30, "Number of times a method must be called after which it is promoted to tier 1.")
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_Tier1CallCountingDelayMs, W("TieredCompilation_Tier1CallCountingDelayMs"), 100, "A perpetual delay in milliseconds that is applied to tier 1 call counting and jitting, while there is tier 0 activity.")
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_Tier1DelaySingleProcMultiplier, W("TieredCompilation_Tier1DelaySingleProcMultiplier"), 10, "Multiplier for TieredCompilation_Tier1CallCountingDelayMs that is applied on a single-processor machine or when the process is affinitized to a single processor.")
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_DisableTier0Jit, W("TieredCompilation_DisableTier0Jit"), 0, "For methods that don't have pregenerated code, disable jitting them at tier 0 and start with a higher tier instead. For methods that have pregenerated code, tiering occurs normally.")

RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_Test_CallCounting, W("TieredCompilation_Test_CallCounting"), 1, "Enabled by default (only activates when TieredCompilation is also enabled). If disabled immediately backpatches prestub, and likely prevents any tier1 promotion")
RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_TieredCompilation_Test_OptimizeTier0, W("TieredCompilation_Test_OptimizeTier0"), 0, "Use optimized codegen (normally used by tier1) in tier0")
#endif

///
/// Quick JIT
///

RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_ForceQuickJit, W("ForceQuickJit"), 0, "For methods that would be jitted, force using quick JIT.")

///
/// Entry point slot backpatch
///
Expand Down
19 changes: 15 additions & 4 deletions src/vm/eeconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,15 @@ HRESULT EEConfig::Init()

#if defined(FEATURE_TIERED_COMPILATION)
fTieredCompilation = false;
fTieredCompilation_DisableTier0Jit = false;
fTieredCompilation_StartupTier_QuickJit = false;
fTieredCompilation_CallCounting = false;
fTieredCompilation_OptimizeTier0 = false;
tieredCompilation_tier1CallCountThreshold = 1;
tieredCompilation_tier1CallCountingDelayMs = 0;
#endif

forceQuickJit = false;

#ifndef CROSSGEN_COMPILE
backpatchEntryPointSlots = false;
#endif
Expand Down Expand Up @@ -1204,10 +1206,11 @@ HRESULT EEConfig::sync()

#if defined(FEATURE_TIERED_COMPILATION)
fTieredCompilation = Configuration::GetKnobBooleanValue(W("System.Runtime.TieredCompilation"), CLRConfig::EXTERNAL_TieredCompilation) != 0;
fTieredCompilation_DisableTier0Jit =

fTieredCompilation_StartupTier_QuickJit =
Configuration::GetKnobBooleanValue(
W("System.Runtime.TieredCompilation.DisableTier0Jit"),
CLRConfig::UNSUPPORTED_TieredCompilation_DisableTier0Jit) != 0;
W("System.Runtime.TieredCompilation.StartupTierQuickJit"),
CLRConfig::UNSUPPORTED_TC_StartupTier_QuickJit) != 0;

fTieredCompilation_CallCounting = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_TieredCompilation_Test_CallCounting) != 0;
fTieredCompilation_OptimizeTier0 = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_TieredCompilation_Test_OptimizeTier0) != 0;
Expand Down Expand Up @@ -1240,6 +1243,14 @@ HRESULT EEConfig::sync()
}
#endif

forceQuickJit = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_ForceQuickJit) != 0;
#ifdef FEATURE_TIERED_COMPILATION
if (forceQuickJit)
{
fTieredCompilation = false;
}
#endif

#ifndef CROSSGEN_COMPILE
backpatchEntryPointSlots = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_BackpatchEntryPointSlots) != 0;
#endif
Expand Down
10 changes: 7 additions & 3 deletions src/vm/eeconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,16 @@ class EEConfig

// Tiered Compilation config
#if defined(FEATURE_TIERED_COMPILATION)
bool TieredCompilation(void) const {LIMITED_METHOD_CONTRACT; return fTieredCompilation; }
bool TieredCompilation_DisableTier0Jit() const { LIMITED_METHOD_CONTRACT; return fTieredCompilation_DisableTier0Jit; }
bool TieredCompilation(void) const { LIMITED_METHOD_CONTRACT; return fTieredCompilation; }
bool TieredCompilation_StartupTier_QuickJit() const { LIMITED_METHOD_CONTRACT; return fTieredCompilation_StartupTier_QuickJit; }
bool TieredCompilation_CallCounting() const {LIMITED_METHOD_CONTRACT; return fTieredCompilation_CallCounting; }
bool TieredCompilation_OptimizeTier0() const {LIMITED_METHOD_CONTRACT; return fTieredCompilation_OptimizeTier0; }
DWORD TieredCompilation_Tier1CallCountThreshold() const { LIMITED_METHOD_CONTRACT; return tieredCompilation_tier1CallCountThreshold; }
DWORD TieredCompilation_Tier1CallCountingDelayMs() const { LIMITED_METHOD_CONTRACT; return tieredCompilation_tier1CallCountingDelayMs; }
#endif

bool ForceQuickJit() const { LIMITED_METHOD_CONTRACT; return forceQuickJit; }

#ifndef CROSSGEN_COMPILE
bool BackpatchEntryPointSlots() const { LIMITED_METHOD_CONTRACT; return backpatchEntryPointSlots; }
#endif
Expand Down Expand Up @@ -1013,13 +1015,15 @@ class EEConfig

#if defined(FEATURE_TIERED_COMPILATION)
bool fTieredCompilation;
bool fTieredCompilation_DisableTier0Jit;
bool fTieredCompilation_StartupTier_QuickJit;
bool fTieredCompilation_CallCounting;
bool fTieredCompilation_OptimizeTier0;
DWORD tieredCompilation_tier1CallCountThreshold;
DWORD tieredCompilation_tier1CallCountingDelayMs;
#endif

bool forceQuickJit;

#ifndef CROSSGEN_COMPILE
bool backpatchEntryPointSlots;
#endif
Expand Down
7 changes: 7 additions & 0 deletions src/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12654,6 +12654,13 @@ CORJIT_FLAGS GetCompileFlags(MethodDesc * ftn, CORJIT_FLAGS flags, CORINFO_METHO
flags.Clear(CORJIT_FLAGS::CORJIT_FLAG_DEBUG_INFO);
}

#ifndef CROSSGEN_COMPILE
if (g_pConfig->ForceQuickJit())
{
flags.Add(CORJIT_FLAGS::CORJIT_FLAG_TIER0);
}
#endif

return flags;
}

Expand Down
4 changes: 4 additions & 0 deletions src/vm/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4803,6 +4803,10 @@ bool MethodDesc::DetermineAndSetIsEligibleForTieredCompilation()
// Functional requirement
CodeVersionManager::IsMethodSupported(this) &&

// Policy - If quick JIT is disabled for the startup tier and the module is not ReadyToRun, the method would effectively
// not be tiered currently, so make the method ineligible for tiering to avoid some unnecessary overhead
(g_pConfig->TieredCompilation_StartupTier_QuickJit() || GetModule()->IsReadyToRun()) &&

// Policy - Debugging works much better with unoptimized code
!CORDisableJITOptimizations(GetModule()->GetDebuggerInfoBits()) &&

Expand Down
2 changes: 1 addition & 1 deletion src/vm/prestub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ PCODE MethodDesc::PrepareILBasedCode(PrepareCodeConfig* pConfig)
if (pCode == NULL)
{
#ifdef FEATURE_TIERED_COMPILATION
if (g_pConfig->TieredCompilation_DisableTier0Jit() &&
if (!g_pConfig->TieredCompilation_StartupTier_QuickJit() &&
IsEligibleForTieredCompilation() &&
pConfig->GetCodeVersion().GetOptimizationTier() == NativeCodeVersion::OptimizationTier0 &&
CallCounter::IsEligibleForTier0CallCounting(this))
Expand Down

0 comments on commit a25a565

Please sign in to comment.