Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
07de069
R2R -> InstrumentedTier0 for hot R2R methods
EgorBo Jun 23, 2022
a7bbfaf
Merge branch 'main' of github.com:dotnet/runtime into tier0instrumented
EgorBo Jun 23, 2022
4b4967b
Oops, it turns out that I didn't properly patch re-used callcountingstub
EgorBo Jun 24, 2022
1392368
remove TieredPGO
EgorBo Jun 24, 2022
1a41355
fix bug in the importer
EgorBo Jun 24, 2022
4828f3e
Add ability to instrument optimized code
EgorBo Jun 24, 2022
1fa264b
fix 32bit
EgorBo Jun 24, 2022
71928f3
fix ret type
EgorBo Jun 24, 2022
127b7d8
Clean up
EgorBo Jun 24, 2022
2cee8a9
Merge branch 'main' of github.com:dotnet/runtime into tier0instrumented
EgorBo Jun 24, 2022
911af8a
Clean up
EgorBo Jun 25, 2022
0316842
test fix
EgorBo Jun 26, 2022
2022e68
test2
EgorBo Jun 26, 2022
246dd95
Merge branch 'main' of github.com:dotnet/runtime into new-tier
EgorBo Jul 14, 2022
3a718af
Address feedback
EgorBo Jul 15, 2022
41733fe
Don't re-use callcountingstubs for now
EgorBo Jul 15, 2022
21c8f6e
Clean up
EgorBo Jul 15, 2022
f37012d
Address feedback
EgorBo Jul 15, 2022
db9c71d
Address feedback
EgorBo Jul 15, 2022
59b2bc9
Add docs
EgorBo Jul 15, 2022
ca5c347
Enable other strategies
EgorBo Jul 16, 2022
a6318a0
Clean up
EgorBo Jul 16, 2022
f75e289
Fix GetInitialOptimizationTier
EgorBo Jul 16, 2022
e9e12ea
Enable optimized Instrumentations
EgorBo Jul 16, 2022
81496c4
Update diagram
EgorBo Jul 16, 2022
be329a1
Fix assert
EgorBo Jul 16, 2022
48e375e
Update
EgorBo Jul 16, 2022
1ac3e19
Add test
EgorBo Jul 16, 2022
f6b457a
Update clrconfigvalues.h
EgorBo Jul 17, 2022
7b9e5d4
Merge branch 'main' of github.com:dotnet/runtime into new-tier
EgorBo Jul 17, 2022
cbddf5b
Update clrconfigvalues.h
EgorBo Jul 17, 2022
9345815
Update clrconfigvalues.h
EgorBo Jul 17, 2022
86523e7
Merge branch 'new-tier' of github.com:EgorBo/runtime-1 into new-tier
EgorBo Aug 6, 2022
6a0c05c
Merge branch 'main' of github.com:dotnet/runtime into new-tier
EgorBo Aug 6, 2022
a073ed7
Resolve conflicts, address feedback
EgorBo Aug 6, 2022
75da822
Apply suggestions from code review
EgorBo Aug 6, 2022
e83eb68
Remove InstrumentedTiers_strat4.csproj
EgorBo Aug 6, 2022
b1f4d2e
Address feedback
EgorBo Aug 6, 2022
acdce3d
Merge branch 'new-tier' of github.com:EgorBo/runtime-1 into new-tier
EgorBo Aug 6, 2022
27f7228
update DynamicPgo-InstrumentedTiers.md
EgorBo Aug 6, 2022
2e478c0
Clean up
EgorBo Aug 6, 2022
557ec0c
Clean up
EgorBo Aug 6, 2022
48cf945
clean up
EgorBo Aug 6, 2022
ca491a0
Rename arg in AsyncPromoteToTier1
EgorBo Aug 6, 2022
25bddf0
Address feedback
EgorBo Aug 6, 2022
f777274
Address feedback
EgorBo Aug 6, 2022
13e1211
Address feedback
EgorBo Aug 7, 2022
15c0e2d
Merge branch 'main' of github.com:dotnet/runtime into new-tier
EgorBo Aug 7, 2022
3d88252
Fix issues found during testing
EgorBo Aug 7, 2022
60a77e5
Merge branch 'main' of github.com:dotnet/runtime into new-tier
EgorBo Oct 13, 2022
df19c68
Simplify PR, get rid of strategies
EgorBo Oct 14, 2022
f46679c
Enable TieredPGO_InstrumentOnlyHotCode by default
EgorBo Oct 14, 2022
4d77f85
Merge branch 'main' of github.com:dotnet/runtime into new-tier
EgorBo Oct 17, 2022
c9bd079
Fix an assert in optimized instrumented tier
EgorBo Oct 18, 2022
d3f205b
fix osr tests
EgorBo Oct 18, 2022
ef4ae58
Update docs
EgorBo Oct 18, 2022
7fd0749
Update DynamicPgo-InstrumentedTiers.md
EgorBo Oct 18, 2022
c4395f8
Address feedback
EgorBo Oct 18, 2022
7fbcf17
Merge branch 'main' of github.com:dotnet/runtime into new-tier
EgorBo Oct 22, 2022
a183996
Address Andy's feedback
EgorBo Oct 22, 2022
ff471e1
Disable edge-profiling with a comment
EgorBo Oct 22, 2022
b202b9f
fix assert
EgorBo Oct 22, 2022
64eb6df
Update docs/design/features/DynamicPgo-InstrumentedTiers.md
EgorBo Oct 24, 2022
07339dc
Fix "mb" in the doc, add one more example to the "perf impact" section
EgorBo Oct 25, 2022
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
Prev Previous commit
Next Next commit
Resolve conflicts, address feedback
  • Loading branch information
EgorBo committed Aug 6, 2022
commit a073ed7e9a190d29ee6f0e7c6244732daab41a0b
3 changes: 1 addition & 2 deletions src/coreclr/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -619,9 +619,8 @@ RETAIL_CONFIG_DWORD_INFO(EXTERNAL_TieredPGO, W("TieredPGO"), 0, "Instrument Tier
// 1 - Use InstrumentedTier for non-R2R code as the initial tier, promote hot R2R to InstrumentedTier
// 2 - [Not tested] Use InstrumentedTier for non-R2R code as the initial tier, promote hot R2R to InstrumentedTierOptimized
// 3 - Promote hot Tier0/R2R to InstrumentedTier
// 4 - [Not tested] Promote hot Tier0/R2R to InstrumentedTierOptimized
//
// Pros & cons of using optimizations inside the instrumented tiers (modes '2' and '4')
// Pros & cons of using optimizations inside the instrumented tiers (mode '2')
// Pros:
// * Lower overhead from instrumentation (and thanks to optimizations we _can_ optimize probes and emit less of those)
// * Optimized code is able to inline methods so we won't be producing new Compilation units for even small methods
Expand Down
21 changes: 21 additions & 0 deletions src/coreclr/vm/eeconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ HRESULT EEConfig::Init()

#if defined(FEATURE_PGO)
fTieredPGO = false;
tieredPGO_Strategy = (TieredPGOStrategy)0;
#endif

#if defined(FEATURE_READYTORUN)
Expand Down Expand Up @@ -701,6 +702,26 @@ HRESULT EEConfig::sync()

#if defined(FEATURE_PGO)
fTieredPGO = Configuration::GetKnobBooleanValue(W("System.Runtime.TieredPGO"), CLRConfig::EXTERNAL_TieredPGO);
tieredPGO_Strategy = (TieredPGOStrategy)CLRConfig::GetConfigValue(CLRConfig::UNSUPPORTED_TieredPGO_Strategy);

// We need quick jit for TieredPGO
if (!fTieredCompilation_QuickJit)
{
fTieredPGO = false;
}
else
{
if (tieredPGO_Strategy == UseInstrumentedTierForILOnly_PromoteHotR2RToInstrumentedTier ||
tieredPGO_Strategy == PromoteHotTier0ToInstrumentedTier)
{
// When we're not using optimizations in the instrumented tiers we produce a lot of new first-time compilation
// due to disabled inlining even for very small methods - such first-time compilations delay promotions by
// tieredCompilation_CallCountingDelayMs
tieredCompilation_CallCountingDelayMs /= 3;
tieredCompilation_CallCountingDelayMs = max(1, tieredCompilation_CallCountingDelayMs);
}
_ASSERTE(tieredPGO_Strategy >= 0 && tieredPGO_Strategy <= 4);
}
#endif

#if defined(FEATURE_TIERED_COMPILATION)
Expand Down
5 changes: 2 additions & 3 deletions src/coreclr/vm/eeconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ enum TieredPGOStrategy
// In these modes we never instrument Tier0 and only promote hot Tier0 and R2R
// code to intermediate tiers with instrumentation
PromoteHotTier0ToInstrumentedTier = 3,
PromoteHotTier0ToInstrumentedTierOptimized = 4,
};

class EEConfig
Expand Down Expand Up @@ -114,7 +113,7 @@ class EEConfig

#if defined(FEATURE_PGO)
bool TieredPGO(void) const { LIMITED_METHOD_CONTRACT; return fTieredPGO; }
TieredPGOStrategy TieredPGO_Strategy(void) const { LIMITED_METHOD_CONTRACT; return fTieredPGO_Strategy; }
TieredPGOStrategy TieredPGO_Strategy(void) const { LIMITED_METHOD_CONTRACT; return tieredPGO_Strategy; }
#endif

#if defined(FEATURE_READYTORUN)
Expand Down Expand Up @@ -681,7 +680,7 @@ class EEConfig

#if defined(FEATURE_PGO)
bool fTieredPGO;
TieredPGOStrategy fTieredPGO_Strategy;
TieredPGOStrategy tieredPGO_Strategy;
#endif

#if defined(FEATURE_READYTORUN)
Expand Down
19 changes: 12 additions & 7 deletions src/coreclr/vm/prestub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,9 @@ PCODE MethodDesc::PrepareILBasedCode(PrepareCodeConfig* pConfig)
if (codeVersion.IsDefaultVersion())
{
pConfig->GetMethodDesc()->GetLoaderAllocator()->GetCallCountingManager()->DisableCallCounting(codeVersion);
_ASSERTE(codeVersion.GetOptimizationTier() != NativeCodeVersion::OptimizationTier0);
_ASSERTE(codeVersion.IsFinalTier());
}
else if (codeVersion.GetOptimizationTier() == NativeCodeVersion::OptimizationTier0)
else if (!codeVersion.IsFinalTier())
{
codeVersion.SetOptimizationTier(NativeCodeVersion::OptimizationTierOptimized);
}
Expand Down Expand Up @@ -457,7 +457,7 @@ PCODE MethodDesc::GetPrecompiledCode(PrepareCodeConfig* pConfig, bool shouldTier
#ifdef FEATURE_TIERED_COMPILATION
if (shouldCountCalls)
{
_ASSERTE(pConfig->GetCodeVersion().GetOptimizationTier() == NativeCodeVersion::OptimizationTier0);
_ASSERTE(!pConfig->GetCodeVersion().IsFinalTier());
pConfig->SetShouldCountCalls();
}
#endif
Expand Down Expand Up @@ -1225,6 +1225,12 @@ PrepareCodeConfig::JitOptimizationTier PrepareCodeConfig::GetJitOptimizationTier
case NativeCodeVersion::OptimizationTierOptimized:
return JitOptimizationTier::Optimized;

case NativeCodeVersion::OptimizationTierInstrumented:
return JitOptimizationTier::InstrumentedTier;

case NativeCodeVersion::OptimizationTierInstrumentedOptimized:
return JitOptimizationTier::InstrumentedTierOptimized;

default:
UNREACHABLE();
}
Expand All @@ -1247,6 +1253,8 @@ const char *PrepareCodeConfig::GetJitOptimizationTierStr(PrepareCodeConfig *conf
case JitOptimizationTier::QuickJitted: return "QuickJitted";
case JitOptimizationTier::OptimizedTier1: return "OptimizedTier1";
case JitOptimizationTier::OptimizedTier1OSR: return "OptimizedTier1OSR";
case JitOptimizationTier::InstrumentedTier: return "InstrumentedTier";
case JitOptimizationTier::InstrumentedTierOptimized: return "InstrumentedTierOptimized";

default:
UNREACHABLE();
Expand Down Expand Up @@ -1293,10 +1301,7 @@ bool PrepareCodeConfig::FinalizeOptimizationTierForTier0LoadOrJit()
// native code version of a method. The current optimization tier should be consistent with the change being made
// (Tier 0 to Optimized), such that the tier is not changed in an unexpected way or at an unexpected time. Since changes
// to the optimization tier are unlocked, this assertion is just a speculative check on possible values.
NativeCodeVersion::OptimizationTier previousOptimizationTier = GetCodeVersion().GetOptimizationTier();
_ASSERTE(
previousOptimizationTier == NativeCodeVersion::OptimizationTier0 ||
previousOptimizationTier == NativeCodeVersion::OptimizationTierOptimized);
_ASSERTE(!GetCodeVersion().IsFinalTier());
#endif // _DEBUG

// Update the tier in the code version. The JIT may have decided to switch from tier 0 to optimized, in which case
Expand Down
13 changes: 5 additions & 8 deletions src/coreclr/vm/tieredcompilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ void TieredCompilationManager::AsyncPromoteToTier1(

NativeCodeVersion::OptimizationTier nextTier = NativeCodeVersion::OptimizationTier1;

#ifdef FEATURE_PGO
// If TieredPGO is enabled, follow TieredPGO_Strategy, see comments in clrconfigvalues.h around it
if (g_pConfig->TieredPGO() && pMethodDesc->IsEligibleForTieredCompilation())
{
Expand All @@ -303,15 +304,15 @@ void TieredCompilationManager::AsyncPromoteToTier1(
nextTier = NativeCodeVersion::OptimizationTierInstrumented;
break;

// 1: Promote hot R2R code to TierInstrumented
// 1: Promote hot R2R code to TierInstrumented
case UseInstrumentedTierForILOnly_PromoteHotR2RToInstrumentedTier:
if (ExecutionManager::IsReadyToRunCode(tier0NativeCodeVersion.GetNativeCode()))
{
nextTier = NativeCodeVersion::OptimizationTierInstrumented;
}
break;

// 2: Promote hot R2R code to TierInstrumentedOptimized
// 2: Promote hot R2R code to TierInstrumentedOptimized
case UseInstrumentedTierForILOnly_PromoteHotR2RToInstrumentedTierOptimized:
if (ExecutionManager::IsReadyToRunCode(tier0NativeCodeVersion.GetNativeCode()))
{
Expand All @@ -324,16 +325,12 @@ void TieredCompilationManager::AsyncPromoteToTier1(
nextTier = NativeCodeVersion::OptimizationTierInstrumented;
break;

// 4: Promote hot Tier0/R2R code to TierInstrumentedOptimized
case PromoteHotTier0ToInstrumentedTierOptimized:
nextTier = NativeCodeVersion::OptimizationTierInstrumentedOptimized;
break;

default:
_ASSERT("Unknown TieredPGO_Strategy");
UNREACHABLE_MSG("Unknown TieredPGO_Strategy");
}
}
}
#endif

ILCodeVersion ilCodeVersion = tier0NativeCodeVersion.GetILCodeVersion();
_ASSERTE(!ilCodeVersion.HasAnyOptimizedNativeCodeVersion(tier0NativeCodeVersion));
Expand Down