-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redefer function bodies #1585
Redefer function bodies #1585
Conversation
Merged with OOP JIT. That was fun. :) |
Fully synched. |
ea45851
to
d6ac8c3
Compare
154d897
to
317462a
Compare
@@ -1763,7 +1763,7 @@ void BailOutRecord::ScheduleFunctionCodeGen(Js::ScriptFunction * function, Js::S | |||
bailOutRecordNotConst->bailOutCount++; | |||
|
|||
Js::FunctionEntryPointInfo *entryPointInfo = function->GetFunctionEntryPointInfo(); | |||
uint8 callsCount = entryPointInfo->callsCount; | |||
uint32 callsCount = entryPointInfo->callsCount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entryPointInfo->totalJittedLoopIterations = UINT8_MAX; | ||
} | ||
uint8 totalJittedLoopIterations = (uint8)entryPointInfo->totalJittedLoopIterations; | ||
uint32 totalJittedLoopIterations = (uint8)entryPointInfo->totalJittedLoopIterations; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
189c0f3
to
0826835
Compare
Reverted to treating call counts as saturating uint8's in bailout code. (Thanks, @rajatd.) |
uint gcSinceLastRedeferral; | ||
uint gcSinceCallCountsCollected; | ||
|
||
static const uint InitialRedeferralDelay = 5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
InitialRedeferralDelay [](start = 22, length = 22)
should we have these as configurable values so we can tune redeferral in the future if need be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea.
@@ -2062,19 +2080,6 @@ ThreadContext::ExecuteRecyclerCollectionFunction(Recycler * recycler, Collection | |||
|
|||
BOOL ret = FALSE; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RedeferFunctionBodies [](start = 23, length = 21)
Correct me if I'm wrong, but I think we should also pass the result of this->GetRedeferralalCollectionInterval() to ScriptContext::RedeferFunctionBodies. Right now, the result of ThreadContext::GetRedeferralInactiveThreshold is being used in FunctionBody::DoRedeferFunction to determine if a function has remained inactive for long enough that it could be redeferred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for explaining offline. No action needed for this comment.
uint inactiveCount; | ||
auto fn = [&](){ inactiveCount = 0xFFFFFFFF; }; | ||
inactiveCount = UInt32Math::Mul(this->GetInactiveCount(), this->GetCompileCount(), fn); | ||
if (inactiveCount < inactiveThreshold) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inactiveCount < inactiveThreshold [](start = 16, length = 33)
The idea here is that if a function was parsed after having been redeferred, make it less likely to be deferred again, right? If so, shouldn't we multiply the threshold by the compileCount?
(Attributes)(this->GetAttributes() & ~(Attributes::DeferredDeserialize | Attributes::DeferredParse)), | ||
Js::FunctionBody::FunctionBodyFlags::Flags_HasNoExplicitReturnValue | ||
#ifdef PERF_COUNTERS | ||
, false /* is function from deferred deserialized proxy */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this assert no longer valid? If so, can we just remove it?
Assert(simpleJitLimit == 0 ? callCount == 0 : simpleJitLimit > callCount); | ||
return callCount == 0 ? | ||
static_cast<uint16>(simpleJitLimit) : | ||
static_cast<uint16>(simpleJitLimit) - callCount - 1; | ||
static_cast<uint16>(simpleJitLimit) - static_cast<uint16>(callCount) - 1; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this just a bug fix?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just silencing any possible complaint about overflow.
else if (!canAllocInPreReservedHeapPageSegment && isAnyJittedCode) | ||
{ | ||
*isAllJITCodeInPreReservedRegion = false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not part of your change, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it's a real issue that my change exposed, probably by causing more re-jitting.
LGTM apart from the comments. |
@dotnet-bot please test Windows x86_release |
b5b2104
to
223b4a9
Compare
eligible for deferred parsing (e.g., not arrow functions, not functions-in-block). Define a force mode in which all eligible functions are redeferred on GC, as well as a 'stress' mode in which all candidates are redeferred on each stack probe.
Merge pull request #1585 from pleath:redefer Redefer function bodies that are not currently being executed and are eligible for deferred parsing (e.g., not arrow functions, not functions-in-block). Define a 'force' mode in which all eligible functions are redeferred on GC, as well as a 'stress' mode in which all candidates are redeferred on each stack probe.
Redefer function bodies that are not currently being executed and are eligible for deferred parsing (e.g., not arrow functions, not functions-in-block). Define a 'force' mode in which all eligible functions are redeferred on GC, as well as a 'stress' mode in which all candidates are redeferred on each stack probe.