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

VM: parts of dart2js are never optimized #33717

Closed
rakudrama opened this issue Jun 30, 2018 · 2 comments
Closed

VM: parts of dart2js are never optimized #33717

rakudrama opened this issue Jun 30, 2018 · 2 comments
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.

Comments

@rakudrama
Copy link
Member

rakudrama commented Jun 30, 2018

Even when dart2js runs for a long time (batch mode), some methods are not optimized

Near the top of the profile you will find something like:

9.21% 9.21% ► 9.21% GCNewSpace
3.46% 3.46% ▼ 3.46% [Stub] OneArgCheckInlineCache
7.94% 1.63%   ► 18.38% Setlet.add
4.66% 0.23%   ▼ 8.09% DominatedUses._compute
4.96% 0.03%     ▼ 100.00% DominatedUses.of

Looking at the code, I see that DominatedUses._compute and Setlet.add are running unoptimized code.
Both account for ~5% of total dart2js compile time, so optimizing the code could net a few percent total gain.

Is there something blocking optimization that we should change?

/cc @mraleph @a-siva

@rakudrama rakudrama added the area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. label Jun 30, 2018
@mraleph mraleph self-assigned this Jun 30, 2018
@mraleph
Copy link
Member

mraleph commented Jun 30, 2018

Thanks for locating this, Stephen! This was the thing I was hunting for the past couple of weeks and I just could not get a grasp on (maybe I was not running dart2js long enough to get a meaningful stack trace).

The underlying bug is misoptimization of monomorphic invocation sites that have type arguments (like cast in Setlet.add). We end up emitting a wrong class check - instead of checking type of the receiver we check type of type arguments - which is always deoptimizes. Which in turn eventually disables optimizations of the method.

This should be fixed by https://dart-review.googlesource.com/c/sdk/+/63380

@mraleph
Copy link
Member

mraleph commented Jun 30, 2018

This brings around 10% improvement in Dart 2 mode for Dart 2 JS on my measurements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

2 participants