From 98a6a9fa5dffdba99585fee5d0496909924f82d1 Mon Sep 17 00:00:00 2001 From: Koundinya Veluri Date: Fri, 17 Aug 2018 08:31:44 -0700 Subject: [PATCH] Enable Tiered Compilation by default (#19525) Port of https://github.com/dotnet/coreclr/pull/19525 to 2.2 1) Changes the default state of the tiered compilation feature check to be ON BY DEFAULT 2) Removed comments about the source about this being a work in progress. Although it will surely continue to evolve and improve, remaining issues would be better tracked in our issue tracking system with the same default presumption as other runtime features - assume it works unless noted otherwise. 3) Adjusts a number of tests and automated scripts that made assumptions that the default setting of this feature is off. 4) Stop accepting the deprecated env var COMPLUS_EXPERIMENTAL_TieredCompilation. I'm not aware it has any remaining usage but if so we're going to find out. 5) Adjust config names for JitBench --- .../project-docs/clr-configuration-knobs.md | 3 +- src/inc/clrconfigvalues.h | 3 +- src/vm/eeconfig.cpp | 4 +-- src/vm/tieredcompilation.cpp | 9 ----- tests/runtest.cmd | 1 + tests/scripts/run-xunit-perf.py | 5 +-- tests/src/CLRTest.Execute.Bash.targets | 12 +++++-- tests/src/CLRTest.Execute.Batch.targets | 12 +++++-- .../stacktrace/Tier1StackTrace.csproj | 10 ------ .../JitBench/Runner/BenchmarkConfiguration.cs | 9 ++--- .../Scenario/JitBench/Runner/Program.cs | 34 +++++++++++++------ .../Tier1Collectible/Tier1Collectible.csproj | 10 ------ 12 files changed, 53 insertions(+), 59 deletions(-) diff --git a/Documentation/project-docs/clr-configuration-knobs.md b/Documentation/project-docs/clr-configuration-knobs.md index b1547daea733..37eebb01eba9 100644 --- a/Documentation/project-docs/clr-configuration-knobs.md +++ b/Documentation/project-docs/clr-configuration-knobs.md @@ -770,8 +770,7 @@ Name | Description | Type | Class | Default Value | Flags Name | Description | Type | Class | Default Value | Flags -----|-------------|------|-------|---------------|------- -`EXPERIMENTAL_TieredCompilation` | Deprecated - Use COMPLUS_TieredCompilation | `DWORD` | `UNSUPPORTED` | `0` | -`TieredCompilation` | Enables tiered compilation | `DWORD` | `EXTERNAL` | `0` | +`TieredCompilation` | Enables tiered compilation | `DWORD` | `EXTERNAL` | `1` | `TieredCompilation_Test_CallCounting` | Enabled by default (only activates when TieredCompilation is also enabled). If disabled immediately backpatches prestub, and likely prevents any tier1 promotion | `DWORD` | `UNSUPPORTED` | `1` | `TieredCompilation_Test_OptimizeTier0` | Use optimized codegen (normally used by tier1) in tier0 | `DWORD` | `UNSUPPORTED` | `0` | `TieredCompilation_Tier1CallCountingDelayMs` | Delay in milliseconds since process startup or the last tier 0 JIT before call counting begins for tier 1 promotion. | `DWORD` | `UNSUPPORTED` | `100` | diff --git a/src/inc/clrconfigvalues.h b/src/inc/clrconfigvalues.h index 503d29dc5280..82d65497e6b9 100644 --- a/src/inc/clrconfigvalues.h +++ b/src/inc/clrconfigvalues.h @@ -650,8 +650,7 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_HillClimbing_GainExponent, /// Tiered Compilation /// #ifdef FEATURE_TIERED_COMPILATION -RETAIL_CONFIG_DWORD_INFO(EXTERNAL_TieredCompilation, W("TieredCompilation"), 0, "Enables tiered compilation") -RETAIL_CONFIG_DWORD_INFO(UNSUPPORTED_LEGACY_TieredCompilation, W("EXPERIMENTAL_TieredCompilation"), 0, "Deprecated - Use COMPLUS_TieredCompilation") +RETAIL_CONFIG_DWORD_INFO(EXTERNAL_TieredCompilation, W("TieredCompilation"), 1, "Enables tiered compilation") 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.") diff --git a/src/vm/eeconfig.cpp b/src/vm/eeconfig.cpp index da4df9431920..3b0fe3d2efb8 100644 --- a/src/vm/eeconfig.cpp +++ b/src/vm/eeconfig.cpp @@ -1240,9 +1240,7 @@ HRESULT EEConfig::sync() dwSleepOnExit = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_SleepOnExit); #if defined(FEATURE_TIERED_COMPILATION) - fTieredCompilation = Configuration::GetKnobBooleanValue(W("System.Runtime.TieredCompilation"), CLRConfig::EXTERNAL_TieredCompilation) || - //this older name is deprecated, but still accepted for a time. Preserving it is a very small overhead not to needlessly break things. - CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_LEGACY_TieredCompilation) != 0; + fTieredCompilation = Configuration::GetKnobBooleanValue(W("System.Runtime.TieredCompilation"), CLRConfig::EXTERNAL_TieredCompilation) != 0; fTieredCompilation_CallCounting = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_TieredCompilation_Test_CallCounting) != 0; fTieredCompilation_OptimizeTier0 = CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_TieredCompilation_Test_OptimizeTier0) != 0; diff --git a/src/vm/tieredcompilation.cpp b/src/vm/tieredcompilation.cpp index 7945973aa9ff..9c9e76de18e3 100644 --- a/src/vm/tieredcompilation.cpp +++ b/src/vm/tieredcompilation.cpp @@ -20,15 +20,6 @@ // handles logistics of getting new code created and installed. // // -// # Current feature state -// -// This feature is a work in progress. It should be functionally correct for a -// good range of scenarios, but performance varies by scenario. To enable it -// you need to set COMPLUS_TieredCompilation = 1. This feature has been -// tested with all of our runtime and CoreFX functional tests, as well as -// diagnostics tests and various partner testing in Visual Studio. -// -// // # Important entrypoints in this code: // // diff --git a/tests/runtest.cmd b/tests/runtest.cmd index 072c2737f918..1603b419b246 100644 --- a/tests/runtest.cmd +++ b/tests/runtest.cmd @@ -80,6 +80,7 @@ if /i "%1" == "GenerateLayoutOnly" (set __GenerateLayoutOnly=1&shift&goto Arg if /i "%1" == "PerfTests" (set __PerfTests=true&shift&goto Arg_Loop) if /i "%1" == "runcrossgentests" (set RunCrossGen=true&shift&goto Arg_Loop) if /i "%1" == "link" (set DoLink=true&set ILLINK=%2&shift&shift&goto Arg_Loop) +REM tieredcompilation is on by default now, but setting this environment variable is harmless and I didn't want to break any automation that might be using it just yet if /i "%1" == "tieredcompilation" (set COMPLUS_TieredCompilation=1&shift&goto Arg_Loop) if /i "%1" == "gcname" (set COMPlus_GCName=%2&shift&shift&goto Arg_Loop) if /i "%1" == "timeout" (set __TestTimeout=%2&shift&shift&goto Arg_Loop) diff --git a/tests/scripts/run-xunit-perf.py b/tests/scripts/run-xunit-perf.py index 18a0b8e446f8..ac5de7b30eaf 100755 --- a/tests/scripts/run-xunit-perf.py +++ b/tests/scripts/run-xunit-perf.py @@ -457,8 +457,9 @@ def main(args): # Set up environment for running tests if optLevel == 'min_opts': myEnv['COMPlus_JITMinOpts'] = '1' - elif optLevel == 'tiered': - myEnv['COMPLUS_TieredCompilation'] = '1' + myEnv['COMPLUS_TieredCompilation'] = '0' + elif optLevel == 'full_opt': + myEnv['COMPLUS_TieredCompilation'] = '0' if not 'XUNIT_PERFORMANCE_MAX_ITERATION' in myEnv: myEnv['XUNIT_PERFORMANCE_MAX_ITERATION'] = '21' diff --git a/tests/src/CLRTest.Execute.Bash.targets b/tests/src/CLRTest.Execute.Bash.targets index a3fecb22a407..5560447363c8 100644 --- a/tests/src/CLRTest.Execute.Bash.targets +++ b/tests/src/CLRTest.Execute.Bash.targets @@ -81,11 +81,17 @@ then exit $(GCBashScriptExitCode) fi ]]> - + diff --git a/tests/src/CLRTest.Execute.Batch.targets b/tests/src/CLRTest.Execute.Batch.targets index 0a6fd439a33c..d17fd3d8b7c0 100644 --- a/tests/src/CLRTest.Execute.Batch.targets +++ b/tests/src/CLRTest.Execute.Batch.targets @@ -76,13 +76,19 @@ IF NOT "%COMPlus_GCStress%"=="" ( Exit /b 0 ) ]]> - + - - - - diff --git a/tests/src/performance/Scenario/JitBench/Runner/BenchmarkConfiguration.cs b/tests/src/performance/Scenario/JitBench/Runner/BenchmarkConfiguration.cs index a72963cec239..bdc8ac7dad3f 100644 --- a/tests/src/performance/Scenario/JitBench/Runner/BenchmarkConfiguration.cs +++ b/tests/src/performance/Scenario/JitBench/Runner/BenchmarkConfiguration.cs @@ -11,18 +11,19 @@ public BenchmarkConfiguration() Name = "Default"; EnvironmentVariables = new Dictionary(); } + public bool IsDefault { get { return Name == "Default"; } } public string Name { get; set; } public Dictionary EnvironmentVariables { get; private set; } - public BenchmarkConfiguration WithTiering() + public BenchmarkConfiguration WithoutTiering() { - return WithModifier("Tiering", "COMPLUS_TieredCompilation", "1"); + return WithModifier("NoTiering", "COMPlus_TieredCompilation", "0"); } public BenchmarkConfiguration WithMinOpts() { - return WithModifier("Minopts", "COMPLUS_JitMinOpts", "1"); + return WithModifier("Minopts", "COMPlus_JitMinOpts", "1"); } public BenchmarkConfiguration WithNoR2R() @@ -32,7 +33,7 @@ public BenchmarkConfiguration WithNoR2R() public BenchmarkConfiguration WithNoNgen() { - return WithModifier("NoNgen", "COMPLUS_ZapDisable", "1"); + return WithModifier("NoNgen", "COMPlus_ZapDisable", "1"); } private BenchmarkConfiguration WithModifier(string modifier, string variableName, string variableValue) diff --git a/tests/src/performance/Scenario/JitBench/Runner/Program.cs b/tests/src/performance/Scenario/JitBench/Runner/Program.cs index fc8615dbf89a..bd664e1e2310 100644 --- a/tests/src/performance/Scenario/JitBench/Runner/Program.cs +++ b/tests/src/performance/Scenario/JitBench/Runner/Program.cs @@ -163,24 +163,24 @@ static IEnumerable GetAllBenchmarks() static IEnumerable GetBenchmarkConfigurations(CommandLineOptions options) { - string tieredEnv = Environment.GetEnvironmentVariable("COMPLUS_TieredCompilation"); - string minoptsEnv = Environment.GetEnvironmentVariable("COMPLUS_JitMinopts"); - string r2rEnv = Environment.GetEnvironmentVariable("COMPLUS_ReadyToRun"); - string ngenEnv = Environment.GetEnvironmentVariable("COMPLUS_ZapDisable"); + string tieredEnv = Environment.GetEnvironmentVariable("COMPlus_TieredCompilation"); + string minoptsEnv = Environment.GetEnvironmentVariable("COMPlus_JitMinopts"); + string r2rEnv = Environment.GetEnvironmentVariable("COMPlus_ReadyToRun"); + string noNgenEnv = Environment.GetEnvironmentVariable("COMPlus_ZapDisable"); BenchmarkConfiguration envConfig = new BenchmarkConfiguration(); - if(tieredEnv != null && tieredEnv != "0") + if(tieredEnv != null && tieredEnv == "0") { - envConfig.WithTiering(); + envConfig.WithoutTiering(); } if (minoptsEnv != null && minoptsEnv != "0") { envConfig.WithMinOpts(); } - if(r2rEnv != null && r2rEnv != "1") + if(r2rEnv != null && r2rEnv == "0") { envConfig.WithNoR2R(); } - if(ngenEnv != null && ngenEnv != "0") + if(noNgenEnv != null && noNgenEnv != "0") { envConfig.WithNoNgen(); } @@ -196,13 +196,25 @@ static IEnumerable GetBenchmarkConfigurations(CommandLin yield break; } + // The minopts config name by itself implies without tiering + var minOptsConfig = new BenchmarkConfiguration().WithMinOpts(); + string minOptsConfigName = minOptsConfig.Name; + minOptsConfig = minOptsConfig.WithoutTiering(); + minOptsConfig.Name = minOptsConfigName; + BenchmarkConfiguration[] possibleConfigs = new BenchmarkConfiguration[] { new BenchmarkConfiguration(), - new BenchmarkConfiguration().WithTiering(), - new BenchmarkConfiguration().WithMinOpts(), + new BenchmarkConfiguration().WithoutTiering(), + minOptsConfig, + new BenchmarkConfiguration().WithMinOpts().WithoutTiering(), + new BenchmarkConfiguration().WithoutTiering().WithMinOpts(), new BenchmarkConfiguration().WithNoR2R(), - new BenchmarkConfiguration().WithNoNgen() + new BenchmarkConfiguration().WithNoR2R().WithoutTiering(), + new BenchmarkConfiguration().WithoutTiering().WithNoR2R(), + new BenchmarkConfiguration().WithNoNgen(), + new BenchmarkConfiguration().WithNoNgen().WithoutTiering(), + new BenchmarkConfiguration().WithoutTiering().WithNoNgen() }; foreach(string configName in configNames) { diff --git a/tests/src/reflection/Tier1Collectible/Tier1Collectible.csproj b/tests/src/reflection/Tier1Collectible/Tier1Collectible.csproj index 926be4a475ac..f77c7cff635f 100644 --- a/tests/src/reflection/Tier1Collectible/Tier1Collectible.csproj +++ b/tests/src/reflection/Tier1Collectible/Tier1Collectible.csproj @@ -18,15 +18,5 @@ - - - -