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
Don't re-use callcountingstubs for now
  • Loading branch information
EgorBo committed Jul 15, 2022
commit 41733fede75f7c0b0cf9015a6842a4cb2d5221c5
1 change: 0 additions & 1 deletion src/coreclr/inc/clrconfigvalues.h
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,6 @@ RETAIL_CONFIG_DWORD_INFO(INTERNAL_TC_DelaySingleProcMultiplier, W("TC_DelaySingl
RETAIL_CONFIG_DWORD_INFO(INTERNAL_TC_CallCounting, W("TC_CallCounting"), 1, "Enabled by default (only activates when TieredCompilation is also enabled). If disabled immediately backpatches prestub, and likely prevents any promotion to higher tiers")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_TC_UseCallCountingStubs, W("TC_UseCallCountingStubs"), 1, "Uses call counting stubs for faster call counting.")
RETAIL_CONFIG_DWORD_INFO(INTERNAL_TC_DeleteCallCountingStubsAfter, W("TC_DeleteCallCountingStubsAfter"), 0, "Deletes call counting stubs after this many have completed. Zero to disable deleting.")

#undef TC_BackgroundWorkerTimeoutMs
#undef TC_CallCountThreshold
#undef TC_CallCountingDelayMs
Expand Down
9 changes: 0 additions & 9 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9101,15 +9101,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
}
#endif

bool IsInstrumented()
{
return jitFlags->IsSet(JitFlags::JIT_FLAG_BBINSTR);
}
bool IsInstrumentedOptimized()
{
return IsInstrumented() && jitFlags->IsSet(JitFlags::JIT_FLAG_TIER1);
}

// true if we should use the PINVOKE_{BEGIN,END} helpers instead of generating
// PInvoke transitions inline. Normally used by R2R, but also used when generating a reverse pinvoke frame, as
// the current logic for frame setup initializes and pushes
Expand Down
9 changes: 4 additions & 5 deletions src/coreclr/jit/fgprofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,7 @@ void BlockCountInstrumentor::Prepare(bool preImport)
//
// If we see any, we need to adjust our instrumentation pattern.
//
if ((m_comp->opts.IsOSR() || m_comp->opts.IsInstrumentedOptimized()) &&
((m_comp->optMethodFlags & OMF_HAS_TAILCALL_SUCCESSOR) != 0))
if (m_comp->opts.IsOSR() && ((m_comp->optMethodFlags & OMF_HAS_TAILCALL_SUCCESSOR) != 0))
{
JITDUMP("OSR + PGO + potential tail call --- preparing to relocate block probes\n");

Expand Down Expand Up @@ -1888,8 +1887,8 @@ PhaseStatus Compiler::fgPrepareToInstrumentMethod()
(JitConfig.TC_PartialCompilation() > 0);
const bool prejit = opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT);
const bool tier0WithPatchpoints = opts.jitFlags->IsSet(JitFlags::JIT_FLAG_TIER0) && mayHavePatchpoints;
const bool useEdgeProfiles =
(JitConfig.JitEdgeProfiling() > 0) && !prejit && !tier0WithPatchpoints && !opts.IsInstrumentedOptimized();
const bool osrMethod = opts.IsOSR();
const bool useEdgeProfiles = (JitConfig.JitEdgeProfiling() > 0) && !prejit && !tier0WithPatchpoints && !osrMethod;

if (useEdgeProfiles)
{
Expand All @@ -1900,7 +1899,7 @@ PhaseStatus Compiler::fgPrepareToInstrumentMethod()
JITDUMP("Using block profiling, because %s\n",
(JitConfig.JitEdgeProfiling() == 0)
? "edge profiles disabled"
: prejit ? "prejitting" : opts.IsInstrumentedOptimized() ? "tier1" : "tier0 with patchpoints");
: prejit ? "prejitting" : osrMethod ? "OSR" : "tier0 with patchpoints");

fgCountInstrumentor = new (this, CMK_Pgo) BlockCountInstrumentor(this);
}
Expand Down
59 changes: 4 additions & 55 deletions src/coreclr/vm/callcounting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,18 +147,13 @@ FORCEINLINE void CallCountingManager::CallCountingInfo::SetStage(Stage stage)
--s_activeCallCountingStubCount;
break;

case Stage::PendingReset:
_ASSERT(m_stage >= Stage::PendingCompletion);
--s_activeCallCountingStubCount;
break;

case Stage::StubMayBeActive:
_ASSERTE(m_callCountingStub != nullptr);
FALLTHROUGH;

case Stage::PendingCompletion:
_ASSERTE(m_stage == Stage::StubIsNotActive || m_stage == Stage::StubMayBeActive || m_stage == Stage::PendingReset);
if ((m_stage == Stage::StubIsNotActive || m_stage == Stage::PendingReset) && m_callCountingStub != nullptr)
_ASSERTE(m_stage == Stage::StubIsNotActive || m_stage == Stage::StubMayBeActive);
if (m_stage == Stage::StubIsNotActive && m_callCountingStub != nullptr)
{
++s_activeCallCountingStubCount;
}
Expand All @@ -183,13 +178,6 @@ FORCEINLINE void CallCountingManager::CallCountingInfo::SetStage(Stage stage)

m_stage = stage;
}

void CallCountingManager::CallCountingInfo::ReuseForNewVersion(NativeCodeVersion version)
{
WRAPPER_NO_CONTRACT;
m_codeVersion = version;
SetStage(Stage::PendingReset);
}
#endif

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -551,28 +539,6 @@ void CallCountingManager::DisableCallCounting(NativeCodeVersion codeVersion)
callCountingInfoHolder.SuppressRelease();
}

void CallCountingManager::ReuseStubForNewVersion(NativeCodeVersion oldVersion, NativeCodeVersion newVersion)
{
CONTRACTL
{
THROWS;
GC_NOTRIGGER;
MODE_ANY;
}
CONTRACTL_END;

CodeVersionManager::LockHolder codeVersioningLockHolder;
CallCountingInfo* callCountingInfo = m_callCountingInfoByCodeVersionHash.Lookup(oldVersion);

// No problem if it's null, it's just an optimization to allocate less call counting stubs
if (callCountingInfo != nullptr)
{
m_callCountingInfoByCodeVersionHash.Remove(oldVersion);
callCountingInfo->ReuseForNewVersion(newVersion);
m_callCountingInfoByCodeVersionHash.Add(callCountingInfo);
}
}

// Returns true if the code entry point was updated to reflect the active code version, false otherwise. In normal paths, the
// code entry point is not updated only when the use of call counting stubs is disabled, as in that case returning to the
// prestub is necessary for further call counting. On exception, the code entry point may or may not have been updated and it's
Expand Down Expand Up @@ -652,19 +618,6 @@ bool CallCountingManager::SetCodeEntryPoint(

do
{
if (callCountingStage == CallCountingInfo::Stage::PendingReset)
{
// Consider using a different threshold here
CallCount callCountThreshold = g_pConfig->TieredCompilation_CallCountThreshold();
_ASSERTE(callCountThreshold != 0);

CallCountingStub *stub = (CallCountingStub*)callCountingInfo->GetCallCountingStub();
// Patch existing CallCountingStub to look at new target
stub->SetTargetForMethod(activeCodeVersion.GetNativeCode());
*callCountingInfo->GetRemainingCallCountCell() = callCountThreshold;
break;
}

if (!wasMethodCalled)
{
break;
Expand Down Expand Up @@ -844,7 +797,7 @@ PCODE CallCountingManager::OnCallCountThresholdReached(TransitionBlock *transiti
}

CallCountingInfo::Stage callCountingStage = callCountingInfo->GetStage();
if (callCountingStage >= CallCountingInfo::Stage::PendingReset)
if (callCountingStage >= CallCountingInfo::Stage::PendingCompletion)
{
break;
}
Expand Down Expand Up @@ -977,11 +930,7 @@ void CallCountingManager::CompleteCallCounting()
methodDesc->ResetCodeEntryPoint();
} while (false);

// stub was about to be completed but we decided to re-use it
if (callCountingInfo->GetStage() != CallCountingInfo::Stage::PendingReset)
{
callCountingInfo->SetStage(CallCountingInfo::Stage::Complete);
}
callCountingInfo->SetStage(CallCountingInfo::Stage::Complete);
}
EX_CATCH
{
Expand Down
12 changes: 1 addition & 11 deletions src/coreclr/vm/callcounting.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ class CallCountingStub

PTR_CallCount GetRemainingCallCountCell() const;
PCODE GetTargetForMethod() const;
void SetTargetForMethod(PCODE code);

protected:

Expand Down Expand Up @@ -183,9 +182,6 @@ class CallCountingManager
// Stub may be called, don't know if it's actually active (changes to code versions, etc.)
StubMayBeActive,

// Stub is being considered to re-use
PendingReset,

// Stub may be active, call counting complete, not yet promoted
PendingCompletion,

Expand All @@ -197,7 +193,7 @@ class CallCountingManager
};

private:
NativeCodeVersion m_codeVersion;
const NativeCodeVersion m_codeVersion;
const CallCountingStub *m_callCountingStub;
CallCount m_remainingCallCount;
Stage m_stage;
Expand Down Expand Up @@ -423,12 +419,6 @@ inline PCODE CallCountingStub::GetTargetForMethod() const
return GetData()->TargetForMethod;
}

inline void CallCountingStub::SetTargetForMethod(PCODE code)
{
WRAPPER_NO_CONTRACT;
InterlockedExchangeT<PCODE>(&GetData()->TargetForMethod, code);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CallCountingManager::CallCountingStubManager

Expand Down