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 optimization #155

Closed
Aetet opened this issue Mar 22, 2017 · 4 comments
Closed

Dart2js optimization #155

Aetet opened this issue Mar 22, 2017 · 4 comments

Comments

@Aetet
Copy link

Aetet commented Mar 22, 2017

Is there any plans for optimizing this library for dart2js? For example for Iterable and use them as JSarray ?

@davidmorgan
Copy link
Collaborator

Could you give more detail about what sort of optimizations you're thinking about, please?

In particular -- do you have a specific use case that you want to speed up?

@ranquild
Copy link

This should go to built_collection repository probably. I too have issues with built collection & dart2js. Consider following code:

List<int> array = <int>[1, 2, 3];
BuiltList<int> list = new BuiltList<int>(array);

int total = 0;

for (int number in array) total += number;
for (int number in list) total += number;

print(total);

Compile it with dart2js main.dart --trust-primitives --trust-type-annotations

for (t1 = array.length, total = 0, _i = 0; t2 = array.length, _i < t2; t2 === t1 || (0, H.throwConcurrentModificationError)(array), ++_i)
  total += array[_i];
for (t1 = list._list, t1 = new J.ArrayIterator(t1, t1.length, 0, null); t1.moveNext$0();)
  total += t1._current;

There is huge performance penalty for using iterator vs using direct array access in a loop. Still, dart2js is able to recognize that there is native array behind list, but not able to generate same efficient code as for using array directly. This is just specific case, but probably same issue is with other methods.

@davidmorgan
Copy link
Collaborator

Created an issue over at built_collection. Please continue discussion there.

@davidmorgan
Copy link
Collaborator

Closing, please reopen if there are built_value specific issues. (As opposed to built_collection). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants