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

Severe performance regression in Dart VM after switching to Dart 2.0 #34054

Closed
mkustermann opened this issue Aug 1, 2018 · 1 comment
Closed
Assignees
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@mkustermann
Copy link
Member

The example at the bottom of this issue (which was reduced from a real world example, without needing --no-background-compilation --enable-inlining-annotations) had orders of magnitude regression:

% out/ReleaseX64/dart --enable-inlining-annotations --no-background-compilation test.dart
Took 0:00:16.288135
% out/ReleaseX64/dart --no-preview-dart-2 --enable-inlining-annotations --no-background-compilation test.dart
Took 0:00:00.090875

This is a slowdown of 180 x!

main() {
  final closure = outer<int, int>();
  final sw = new Stopwatch()..start();
  for (int i = 0; i < 10000000; ++i) {
    fooClosure(closure);
  }
  print('Took ${sw.elapsed}');
}

final dynamic fooClosure = foo;

@NeverInline
foo(FI arg) { }

B Function(A) outer<A, B>() {
  B inner(A a) => null;
  return inner;
}

typedef FI = int Function(int);
const NeverInline = 'NeverInline';

The cause for this slowdown is that we have no fast cases for type tests where the instance tested against is a closure which has a direct or indirect parent function with type parameters.

This is most likely a problem for all users of package:stack_trace on the Dart VM - which is a real problem!

While looking at this I've also discovered a bug in the implementation of function subtyping implementation -- see #34051 .

I've started working on this now.

@mkustermann mkustermann added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Aug 1, 2018
@mkustermann mkustermann self-assigned this Aug 1, 2018
@mkustermann
Copy link
Member Author

@isoos @sortie

This performance issue is a reproduction of the issue the pub site has on Dart 2 and was fixed in 575a8f8. So you could try to switch to a Dart 2 sdk again and do a load test. That being said, JIT in Dart 2.0 is still slower than Dart 1.

tekknolagi pushed a commit to tekknolagi/dart-assembler that referenced this issue Nov 3, 2020
Until now the subtype-test cache mechanism did not work (i.e. could
return the wrong result) for partially instantiated generic closures.

Additionally, closures which close over generic methods were always
handled in runtime.  This caused a servere performance regression for
any code hitting this (e.g. code which uses `package:stack_trace`).

Fixes dart-lang#34051
Fixes dart-lang#34054

Change-Id: Idb73e6f348c2fe0c737f42c57009f5f7a636c9a6
Reviewed-on: https://dart-review.googlesource.com/68369
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
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, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

1 participant