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

Optimize Dart version #81

Merged
merged 1 commit into from
Oct 3, 2023
Merged

Conversation

mraleph
Copy link
Contributor

@mraleph mraleph commented Oct 3, 2023

Main changes:

  • Dart's AOT compiler looses track of concrete types when containers-containing-other-containers are involved, e.g. Map<K, List<T>> or List<List<T>>. This makes operations wither nested containers slower. To work-around this problem you can simply wrap a nested container into some unique class - this helps AOT compiler to realise what comes from the container.
  • Iterable.fillRange is slow - manually inlining it helps (I will file a bug against Dart to fix this).
  • for-in is better than forEach when concrete types are properly known to the compiler (see the first item)
  • Rewrote computation of top 5 to avoid unnecessary allocations

@mraleph
Copy link
Contributor Author

mraleph commented Oct 3, 2023

These changes improve Dart AOT performance from 183ms to 100ms on my machine (measured on HEAD of Dart SDK - the upcoming release has a bunch of improvements which make for-in perform better in AOT mode).

@jinyus
Copy link
Owner

jinyus commented Oct 3, 2023

Thanks for the PR. Very insightful. Drops from 70ms -> 55 on my machine.

@jinyus jinyus merged commit 4f4fa3e into jinyus:main Oct 3, 2023
@jinyus jinyus mentioned this pull request Jan 5, 2024
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

Successfully merging this pull request may close these issues.

2 participants