Skip to content
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

use ForInCache for enumerator in Object.assign #4852

Merged
merged 4 commits into from
Mar 26, 2018

Conversation

MikeHolman
Copy link
Contributor

@MikeHolman MikeHolman commented Mar 21, 2018

Adds a per-ScriptContext polymorphic cache of size 16 for Object.assign.
Preliminary perf looks like it improves React-redux by about 8%.

Full perf run gave me numbers that are too good to be true (5% geomean improvement), but I'm not sure I believe it.

@MikeHolman
Copy link
Contributor Author

For reviewing convenience, I have the renaming as a separate commit

{
if (Cache()->assignCache)
{
memset(Cache()->assignCache, 0, Js::Cache::AssignCacheSize);
Copy link
Contributor Author

@MikeHolman MikeHolman Mar 21, 2018

Choose a reason for hiding this comment

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

oops, * sizeof(EnumeratorCache)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually... i should just use the forInCacheAllocator


In reply to: 176248209 [](ancestors = 176248209)

@agarwal-sandeep
Copy link
Collaborator

        symbolMap(nullptr),

initialize assignCache to nullptr


Refers to: lib/Runtime/Library/JavascriptLibrary.h:551 in 2b7744c. [](commit_id = 2b7744c, deletion_comment = False)

this->cache.assignCache = AllocatorNewArrayZ(CacheAllocator, scriptContext->GetEnumeratorAllocator(), EnumeratorCache, Cache::AssignCacheSize);
}

return &this->cache.assignCache[(((size_t)type) >> PolymorphicInlineCacheShift) & (Cache::AssignCacheSize - 1)];
Copy link
Contributor

Choose a reason for hiding this comment

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

AssignCacheSize [](start = 98, length = 15)

Maybe we could add a static assertion that AssignCacheSize is a power of 2, to avoid surprising out-of-bounds behavior if someone tries tweaking the constant.

@@ -390,7 +390,7 @@ namespace Js
static void OP_InitComputedProperty(Var object, Var elementName, Var value, ScriptContext* scriptContext, PropertyOperationFlags flags = PropertyOperation_None);
static void OP_InitProto(Var object, PropertyId propertyId, Var value);

static void OP_InitForInEnumerator(Var enumerable, ForInObjectEnumerator * enumerator, ScriptContext* scriptContext, ForInCache * forInCache = nullptr);
static void OP_InitForInEnumerator(Var enumerable, ForInObjectEnumerator * enumerator, ScriptContext* scriptContext, EnumeratorCache * forInCache = nullptr);
Copy link
Contributor

@sethbrenith sethbrenith Mar 21, 2018

Choose a reason for hiding this comment

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

forInCache [](start = 143, length = 10)

Nit: could rename this param for consistency with others (and in corresponding cpp) #ByDesign

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left this one on purpose because it is used specifically for for in

Copy link
Contributor

Choose a reason for hiding this comment

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

good point


In reply to: 176263509 [](ancestors = 176263509)

Copy link
Contributor

@sethbrenith sethbrenith left a comment

Choose a reason for hiding this comment

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

:shipit:

Copy link
Contributor

@curtisman curtisman left a comment

Choose a reason for hiding this comment

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

:shipit:

@chakrabot chakrabot merged commit 52e4943 into chakra-core:master Mar 26, 2018
chakrabot pushed a commit that referenced this pull request Mar 26, 2018
Merge pull request #4852 from MikeHolman:assigncache

Adds a per-ScriptContext polymorphic cache of size 16 for Object.assign.
Preliminary perf looks like it improves React-redux by about 8%.

Full perf run gave me numbers that are too good to be true (5% geomean improvement), but I'm not sure I believe it.
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.

6 participants