Skip to content

Redefer function bodies - #1585

Merged
chakrabot merged 1 commit into
chakra-core:masterfrom
pleath:redefer
Nov 11, 2016
Merged

Redefer function bodies#1585
chakrabot merged 1 commit into
chakra-core:masterfrom
pleath:redefer

Conversation

@pleath

@pleath pleath commented Sep 15, 2016

Copy link
Copy Markdown
Contributor

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.

@pleath

pleath commented Oct 22, 2016

Copy link
Copy Markdown
Contributor Author

Merged with OOP JIT. That was fun. :)

@pleath

pleath commented Oct 22, 2016

Copy link
Copy Markdown
Contributor Author

Fully synched.

Comment thread lib/Backend/BailOut.cpp Outdated

Js::FunctionEntryPointInfo *entryPointInfo = function->GetFunctionEntryPointInfo();
uint8 callsCount = entryPointInfo->callsCount;
uint32 callsCount = entryPointInfo->callsCount;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @LouisLaf mentioned in #1757, we should have callsCount be MIN of entryPointInfo->callsCount and 255

Comment thread lib/Backend/BailOut.cpp Outdated
entryPointInfo->totalJittedLoopIterations = UINT8_MAX;
}
uint8 totalJittedLoopIterations = (uint8)entryPointInfo->totalJittedLoopIterations;
uint32 totalJittedLoopIterations = (uint8)entryPointInfo->totalJittedLoopIterations;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should retain the previous rejit behaviour in keeping with @LouisLaf 's suggestion in #1757

@pleath
pleath force-pushed the redefer branch 2 times, most recently from 189c0f3 to 0826835 Compare November 8, 2016 01:12
@pleath

pleath commented Nov 8, 2016

Copy link
Copy Markdown
Contributor Author

Reverted to treating call counts as saturating uint8's in bailout code. (Thanks, @rajatd.)

uint gcSinceLastRedeferral;
uint gcSinceCallCountsCollected;

static const uint InitialRedeferralDelay = 5;

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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;

Copy link
Copy Markdown
Contributor

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.

Copy link
Copy Markdown
Contributor

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.

Comment thread lib/Runtime/Base/FunctionBody.cpp Outdated
uint inactiveCount;
auto fn = [&](){ inactiveCount = 0xFFFFFFFF; };
inactiveCount = UInt32Math::Mul(this->GetInactiveCount(), this->GetCompileCount(), fn);
if (inactiveCount < inactiveThreshold)

Copy link
Copy Markdown
Contributor

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 */

Copy link
Copy Markdown
Contributor

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?

static_cast<uint16>(simpleJitLimit) - callCount - 1;
static_cast<uint16>(simpleJitLimit) - static_cast<uint16>(callCount) - 1;
}

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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;
}

Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor Author

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.

@rajatd

rajatd commented Nov 10, 2016

Copy link
Copy Markdown
Contributor

LGTM apart from the comments.

@pleath pleath changed the title Redefer function bodies (experimental) Redefer function bodies Nov 10, 2016
@pleath

pleath commented Nov 10, 2016

Copy link
Copy Markdown
Contributor Author

@dotnet-bot please test Windows x86_release

@pleath
pleath force-pushed the redefer branch 2 times, most recently from b5b2104 to 223b4a9 Compare November 11, 2016 01:28
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.
@chakrabot
chakrabot merged commit a384d2e into chakra-core:master Nov 11, 2016
chakrabot pushed a commit that referenced this pull request Nov 11, 2016
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants