Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(80)

Issue 2829603002: Fall back to megamorphic stub when dispatching calls to rare classes. (Closed)

Created:
3 years, 8 months ago by erikcorry
Modified:
3 years, 8 months ago
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Fall back to megamorphic stub when dispatching calls to rare classes. Previously we were converting very polymorphic calls that always end up in the same implementation into a check-class instruction and a (usually inlined) direct call. This works well in artificial benchmarks like the Megamorphic suite, but tends to cause repeated deopts on large real programs like dart2js, where new classes arrive after a while, triggering the check-class instruction to deopt. After a few deopts, the function is no longer eligible for optimization, resulting in huge slowdowns. Instead with this change we can switch to the normal machinery for polymorphic calls with more than one target. This has the advantage that we use a megamorphic stub call to catch rare classes, rather than deopting. Dart2js is speeded up by a few percent on average and avoids the big performance potholes described in https://github.com/dart-lang/sdk/issues/29302 Also reverts a less effective workaround for 29302. R=vegorov@google.com BUG=29302 Committed: https://github.com/dart-lang/sdk/commit/0856863355595088aac6a519a77a2e6987bf26cf

Patch Set 1 #

Total comments: 2

Patch Set 2 : Added comment and used call site deopt history to control #

Patch Set 3 : Added comment and used call site deopt history to control #

Unified diffs Side-by-side diffs Delta from patch set Stats (+14 lines, -13 lines) Patch
M runtime/vm/jit_optimizer.cc View 1 2 chunks +13 lines, -12 lines 0 comments Download
M runtime/vm/object.h View 1 2 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 9 (2 generated)
erikcorry
3 years, 8 months ago (2017-04-19 08:04:24 UTC) #1
Vyacheslav Egorov (Google)
LGTM Can we update artificial Megamorphic benchmark to exhibit similar behavior? (e.g. as an additional ...
3 years, 8 months ago (2017-04-19 08:24:00 UTC) #2
erikcorry
https://codereview.chromium.org/2829603002/diff/1/runtime/vm/jit_optimizer.cc File runtime/vm/jit_optimizer.cc (right): https://codereview.chromium.org/2829603002/diff/1/runtime/vm/jit_optimizer.cc#newcode1621 runtime/vm/jit_optimizer.cc:1621: const int max_cids = (op_kind == Token::kEQ) On 2017/04/19 ...
3 years, 8 months ago (2017-04-19 13:15:41 UTC) #4
Vyacheslav Egorov (Google)
still lgtm
3 years, 8 months ago (2017-04-19 13:21:55 UTC) #5
erikcorry
Committed patchset #3 (id:40001) manually as 0856863355595088aac6a519a77a2e6987bf26cf (presubmit successful).
3 years, 8 months ago (2017-04-19 13:25:31 UTC) #7
Cutch
How does this change affect flutter applications?
3 years, 8 months ago (2017-04-19 15:48:04 UTC) #8
erikcorry
3 years, 8 months ago (2017-04-20 07:04:28 UTC) #9
Message was sent while issue was closed.
On 2017/04/19 15:48:04, Cutch wrote:
> How does this change affect flutter applications?

I don't expect any changes.  Does Golem have any benchmarks that reflect Flutter
apps?

It makes things more like they were a few weeks ago for a few very "polymorphic"
call sites that have only one target (ie they are not really polymorphic, it's
just a very wide class hierarchy).  Until recently they were generated as a call
to the megamorphic stub which did a hash table lookup on every invocation only
to always call the same method.  Until yesterday that was replaced with a class
ID check and a direct call (often inlined).  Now you get the same sort of thing,
but there's a call to the stub instead of a deopt if a new or rare receiver
class is seen.

Powered by Google App Engine
This is Rietveld 408576698