Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

Re-export performance #386

Closed
Closed
@guybedford

Description

@guybedford

Re-exports in the System.register module format call the setter functions for each export successively such that the setter functions get run all the way to the top of the dependency tree of exponential order in the depth of the re-exporting.

Aurelia currently has re-exporting depths of at least 4, which means that 10 deep exports becomes of the order of 10^4 setter runs, which is causing performance issues for them.

The proposal to fix this is to provide a bulk-export variation of the _export function in the System.register format that takes any object containing key value pairs (optionally an entire module object for export *) as arguments instead of key, value.

This way:

export * from 'p';

Can be written as:

System.register(['p'], function(_export) {
  return {
    setters: [function(m) {
      _export(m);
    }]
    execute: function() {}
  };
});

Then in the implementation, this single export function means this triggers a single bulk export event up the tree depth making the setter count O(1^d) instead of O(n^d) for the number of re-exports.

Normal rexport statements can also use the same logic:

export {p, q, r as s} from 'p';

can be written:

System.register(['p'], function(_export) {
  return {
    setters: [function(m) {
      _export({
        p: m.p,
        q: m.q,
        s: m.r
      });
    }]
    execute: function() {}
  };
});

I'll aim to create an implementation for this in Traceur after this coming major release and include it in a coming patch. I may have overlooked something having not yet tested this theory out completely, so will report back when I've got full confirmation that the above optimization is working and we can include it in the other transpilers.

/cc @EisenbergEffect @sebmck @vladima

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions