Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita593f58

Browse files
authored
JIT: preliminary version of profile-based inline policy (#44427)
Add a new inline policy that can be used when a method has profile data.It uses the call site frequency to boost profitability. Size and per-callbenefit are currently using the estimates done by the model policy.Not on by default. Set COMPlus_JitInlinePolicyProfile=1 to enable.Add testing to weekly experimental runs.
1 parent0efefa8 commita593f58

File tree

9 files changed

+329
-6
lines changed

9 files changed

+329
-6
lines changed

‎eng/pipelines/common/templates/runtimes/run-test-job.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ jobs:
471471
-jitehwritethru
472472
-jitobjectstackallocation
473473
-jitpgo
474+
-jitpgo_inline
474475
${{ if in(parameters.testGroup, 'ilasm') }}:
475476
scenarios:
476477
-ilasmroundtrip

‎src/coreclr/src/jit/importer.cpp‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18894,6 +18894,25 @@ void Compiler::impMakeDiscretionaryInlineObservations(InlineInfo* pInlineInfo, I
1889418894

1889518895
inlineResult->NoteInt(InlineObservation::CALLSITE_FREQUENCY, static_cast<int>(frequency));
1889618896
inlineResult->NoteInt(InlineObservation::CALLSITE_WEIGHT, static_cast<int>(weight));
18897+
18898+
// If the call site has profile data, report the relative frequency of the site.
18899+
//
18900+
if ((pInlineInfo != nullptr) && pInlineInfo->iciBlock->hasProfileWeight())
18901+
{
18902+
double callSiteWeight = (double)pInlineInfo->iciBlock->bbWeight;
18903+
double entryWeight = (double)impInlineRoot()->fgFirstBB->bbWeight;
18904+
18905+
assert(callSiteWeight >= 0);
18906+
assert(entryWeight >= 0);
18907+
18908+
if (entryWeight != 0)
18909+
{
18910+
inlineResult->NoteBool(InlineObservation::CALLSITE_HAS_PROFILE, true);
18911+
18912+
double frequency = callSiteWeight / entryWeight;
18913+
inlineResult->NoteDouble(InlineObservation::CALLSITE_PROFILE_FREQUENCY, frequency);
18914+
}
18915+
}
1889718916
}
1889818917

1889918918
/*****************************************************************************

‎src/coreclr/src/jit/inline.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,8 @@ void InlineContext::Dump(unsigned indent)
390390
if (m_Parent ==nullptr)
391391
{
392392
// Root method
393-
printf("Inlines into %08X %s\n", calleeToken, calleeName);
393+
InlinePolicy* policy =InlinePolicy::GetPolicy(compiler,true);
394+
printf("Inlines into %08X [via %s] %s\n", calleeToken, policy->GetName(), calleeName);
394395
}
395396
else
396397
{

‎src/coreclr/src/jit/inline.def‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,16 @@ INLINE_OBSERVATION(RARE_GC_STRUCT, bool, "rarely called, has gc str
165165
INLINE_OBSERVATION(CONSTANT_ARG_FEEDS_TEST, bool, "constant argument feeds test", INFORMATION, CALLSITE)
166166
INLINE_OBSERVATION(DEPTH, int, "depth", INFORMATION, CALLSITE)
167167
INLINE_OBSERVATION(FREQUENCY, int, "rough call site frequency", INFORMATION, CALLSITE)
168+
INLINE_OBSERVATION(HAS_PROFILE, bool, "profile data is available", INFORMATION, CALLSITE)
168169
INLINE_OBSERVATION(IN_LOOP, bool, "call site is in a loop", INFORMATION, CALLSITE)
169170
INLINE_OBSERVATION(IN_TRY_REGION, bool, "call site is in a try region", INFORMATION, CALLSITE)
170171
INLINE_OBSERVATION(IS_PROFITABLE_INLINE, bool, "profitable inline", INFORMATION, CALLSITE)
171172
INLINE_OBSERVATION(IS_SAME_THIS, bool, "same this as root caller", INFORMATION, CALLSITE)
172173
INLINE_OBSERVATION(IS_SIZE_DECREASING_INLINE, bool, "size decreasing inline", INFORMATION, CALLSITE)
173174
INLINE_OBSERVATION(LOG_REPLAY_ACCEPT, bool, "accepted by log replay", INFORMATION, CALLSITE)
175+
INLINE_OBSERVATION(PROFILE_FREQUENCY, double, "frequency from profile data", INFORMATION, CALLSITE)
174176
INLINE_OBSERVATION(RANDOM_ACCEPT, bool, "random accept", INFORMATION, CALLSITE)
175-
INLINE_OBSERVATION(WEIGHT, int, "call sitefrequency", INFORMATION, CALLSITE)
177+
INLINE_OBSERVATION(WEIGHT, int, "frequency from block weight", INFORMATION, CALLSITE)
176178

177179
// ------ Final Sentinel -------
178180

‎src/coreclr/src/jit/inline.h‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ class InlinePolicy
225225
virtualvoidNoteSuccess() = 0;
226226
virtualvoidNoteBool(InlineObservation obs,bool value) = 0;
227227
virtualvoidNoteFatal(InlineObservation obs) = 0;
228-
virtualvoidNoteInt(InlineObservation obs,int value) = 0;
228+
virtualvoidNoteInt(InlineObservation obs,int value) = 0;
229+
virtualvoidNoteDouble(InlineObservation obs,double value) = 0;
229230

230231
// Optional observations. Most policies ignore these.
231232
virtualvoidNoteContext(InlineContext* context)
@@ -396,6 +397,12 @@ class InlineResult
396397
m_Policy->NoteInt(obs, value);
397398
}
398399

400+
// Make an observation with a double value
401+
voidNoteDouble(InlineObservation obs,double value)
402+
{
403+
m_Policy->NoteDouble(obs, value);
404+
}
405+
399406
#if defined(DEBUG) || defined(INLINE_DATA)
400407

401408
// Record observation from an earlier failure.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp