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

Improve instance calls in JIT optimized code #36731

Open
zanderso opened this issue Apr 24, 2019 · 3 comments

Comments

Projects
None yet
4 participants
@zanderso
Copy link
Member

commented Apr 24, 2019

Related to issue #36428

@alexmarkov identified that the OneArgCheckInlineCacheStub is hot in JIT optimized code coming from bytecode in a representative Flutter app running on Fuchsia. Improving the stub, or reorganizing instance calls in optimized code would presumably improve fps there.

@rmacnak-google @a-siva

@alexmarkov

This comment has been minimized.

Copy link
Contributor

commented Apr 25, 2019

It looks like OneArgCheckInlineCache is only used in unoptimized code, and observatory profiler incorrectly shows that it is called from optimized code. Anyway, we have almost 15% ticks in OneArgCheckInlineCache, so it is worth looking at that stub.

@rmacnak-google

This comment has been minimized.

Copy link
Member

commented Apr 25, 2019

dart-bot pushed a commit that referenced this issue May 20, 2019

[vm] Re-order ICData entries to allow CID and count to be accessed wi…
…th a load-pair.

Bug: #36731
Change-Id: Ia91ddb7e8991a5ab227ab8758173a99141c259be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103004
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>

dart-bot pushed a commit that referenced this issue May 21, 2019

[vm, compiler] Fix Code checked entry offsets.
Function entry points have been subject to block scheduling since 06f9a9e. Block scheduling in AOT never reorders the entries.

Bug: #36409
Bug: #36731
Change-Id: Id6725fed4d9bbd381631fa88c5397435a35acc9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102463
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>

dart-bot pushed a commit that referenced this issue May 21, 2019

[vm, compiler] Unoptimized megamorphic calls.
When an instance call in unoptimized code creates more than FLAG_max_polymorphic_checks cases, switch the call to use a MegamorphicCache instead of ICData. The prevents unbounded collection of type feedback, and gives improvements on microbenchmarks in the 3-8% range for unoptimized code.

It also leads to a loss of target frequency information for the optimizer, leading to different ordering for range checks in polymorphic inlining. This leads to changes on megamorphic microbenchmarks from -31% to +60%, weighted toward the negative end.

In practice the frequency information seems unimportant, as dart2js has 4.01% geomean improvement.

This is a step toward direct monomorphic calls in unoptimized code, which will also make use of the patching and type feedback extraction added here.

Bug: #26780
Bug: #36409
Bug: #36731
Change-Id: I29f53f23b6794c5f5f0db8b8184788cee16fd9c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99270
Reviewed-by: Alexander Markov <alexmarkov@google.com>

dart-bot pushed a commit that referenced this issue May 22, 2019

Revert "[vm, compiler] Unoptimized megamorphic calls."
This reverts commit fde6a59.

Reason for revert: This commit looks to be causing new test failures on dart2js. While there are some odd results on some builders that look like infra failures, some builders (for example, dart2js-minified-strong-linux-x64-d8) show the new failing tests clearly.

Original change's description:
> [vm, compiler] Unoptimized megamorphic calls.
> 
> When an instance call in unoptimized code creates more than FLAG_max_polymorphic_checks cases, switch the call to use a MegamorphicCache instead of ICData. The prevents unbounded collection of type feedback, and gives improvements on microbenchmarks in the 3-8% range for unoptimized code.
> 
> It also leads to a loss of target frequency information for the optimizer, leading to different ordering for range checks in polymorphic inlining. This leads to changes on megamorphic microbenchmarks from -31% to +60%, weighted toward the negative end.
> 
> In practice the frequency information seems unimportant, as dart2js has 4.01% geomean improvement.
> 
> This is a step toward direct monomorphic calls in unoptimized code, which will also make use of the patching and type feedback extraction added here.
> 
> Bug: #26780
> Bug: #36409
> Bug: #36731
> Change-Id: I29f53f23b6794c5f5f0db8b8184788cee16fd9c5
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99270
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com,ajcbik@google.com

Change-Id: Icad46b93cdf8541a00563f49da6b4ac0a4df1ba1
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: #26780, #36409, #36731
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103440
Reviewed-by: Teagan Strickland <sstrickl@google.com>
Commit-Queue: Teagan Strickland <sstrickl@google.com>

dart-bot pushed a commit that referenced this issue Jun 12, 2019

[vm, compiler] Specialize unoptimized monomorphic and megamorphic calls.
dart-bytecode, arm64:            +4.742% geomean
dart-bytecode-jit-unopt, arm64: +12.73% geomean
dart2js-compile, x64:            +3.635% geomean

In the polymorphic and unlinked cases, call to a stub the does a linear scan against an ICData.

In the monomorphic case, call to a prologue of the expected target function that checks the expected receiver class. There is additional indirection in the JIT version compared to the AOT version to also tick a usage counter so the inliner can make good decisions.

In the megamorphic case, call to a stub that does a hash table lookup against a MegamorphicCache.

Megamorphic call sites face a loss of precision in usage counts. The call site count is not recorded and the usage counter of the target function is used as an approximation.

Monomorphic and megamorphic calls sites are reset to the polymorphic/unlinked state on hot reload.

Monomorphic and megamorphic calls sites do not check the stepping state, so they are reset to the polymorphic/unlinked state when stepping begins and disabled.

Back-edges now increment the usage counter in addition to checking it. This ensures function with loops containing monomorphic calls will eventually cross the optimization threshold.

Fixed backwards use of kMonomorphicEntryOffset and kPolymorphicEntryOffset.

Fixed C stack overflow when bouncing between the KBC interpreter and a simulator.

Bug: #26780
Bug: #36409
Bug: #36731
Change-Id: I78a49cccd962703a459288e71ce246ed845df474
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102820
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
@a-siva

This comment has been minimized.

Copy link
Contributor

commented Jul 2, 2019

Can this issue be closed, rmacnak@ has landed some related CLs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.