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

dart2js kernel: DeferredImportsTask is slow #31520

Open
rakudrama opened this issue Dec 1, 2017 · 2 comments
Open

dart2js kernel: DeferredImportsTask is slow #31520

rakudrama opened this issue Dec 1, 2017 · 2 comments
Assignees
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. dart2js-kernel web-dart2js

Comments

@rakudrama
Copy link
Member

On a large app, the AST pipeline spends ~2s in DeferredImportsTask, the Kernel pipeline ~20s.

Profiling shows ~8% on the line below starting with .any(.

It seems like collecting the additionalExports into a cached Set would fix the immediate performance problem.

  @override
  Iterable<ImportEntity> importsTo(Entity element, LibraryEntity library) {
    if (element is! MemberEntity) return const <ImportEntity>[];
    List<ImportEntity> imports = [];
    ir.Library source = _elementMap.getLibraryNode(library);
    ir.Member member = _elementMap.getMemberDefinition(element).node;
    for (ir.LibraryDependency dependency in source.dependencies) {
      if (dependency.isExport) continue;
      if (!_isVisible(dependency.combinators, member.name.name)) continue;
      if (member.enclosingLibrary == dependency.targetLibrary ||
          dependency.targetLibrary.additionalExports
              .any((ir.Reference ref) => ref.node == member)) {
        imports.add(_elementMap.getImport(dependency));
      }
    }
    return imports;
  }
@sigmundch
Copy link
Member

To document our plan here:

  • we'll temporarily do something simple in dart2js to improve performance of this method (e.g. caching of additionalExports as a set)
  • later we want to improve deferred loading so that it operates at a finer granularity: we have enough information during resolution so we can record how dependencies exist between elements, so we should need to be using the import graph entirely. One idea we like is to attach to each method some metadata that indicates which entities it depends on, and through which deferred import they were used.

@rakudrama
Copy link
Member Author

Temporary speedup via caching additionalExports: from ~20s to ~5-6s: https://dart-review.googlesource.com/c/sdk/+/25740
This is not as fast as the ~2s for the other version.

whesse pushed a commit that referenced this issue Dec 6, 2017
Cache additionalExports as a Set to speed up kernel version of deferred loading

Bug: #31520
Change-Id: I0c67c2c0255bbbd3a4c844bae3a3b8ecf2233e13
Reviewed-on: https://dart-review.googlesource.com/25740
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
@vsmenon vsmenon added the area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. label Jul 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. dart2js-kernel web-dart2js
Projects
None yet
Development

No branches or pull requests

3 participants