Skip to content

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 MikeHolman requested review from curtisman and rajatd March 21, 2018 21:40
@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)

@MikeHolman MikeHolman requested a review from sethbrenith March 21, 2018 22:08
@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.

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

6 participants