Skip to content

Performance of generic tupes #6524

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

Closed
nicolasstucki opened this issue May 16, 2019 · 5 comments
Closed

Performance of generic tupes #6524

nicolasstucki opened this issue May 16, 2019 · 5 comments

Comments

@nicolasstucki
Copy link
Contributor

Compiling

(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22).tail

is 5X faster that compiling

(1 *: 2 *: 3 *: 4 *: 5 *: 6 *: 7 *: 8 *: 9 *: 10 *: 11 *: 12 *: 13 *: 14 *: 15 *: 16 *: 17 *: 18 *: 19 *: 20 *: 21 *: 22 *: ()).tail
70.956 ±(99.9%) 0.702 ms/op [Average]
  (min, avg, max) = (69.699, 70.956, 72.428), stdev = 0.809

vs

360.557 ±(99.9%) 8.647 ms/op [Average]
  (min, avg, max) = (348.357, 360.557, 384.038), stdev = 9.958
@OlivierBlanvillain
Copy link
Contributor

How does it look without the .tail?

@nicolasstucki
Copy link
Contributor Author

Does not change much. I did some experiments and it looks like the performance loss depends on the amount on generated code and the number of cases in inline matches.

@milessabin
Copy link
Contributor

It'd be worth doing some benchmarks against the equivalents using nested pairs rather than tuples. They're almost certainly going to win for things like head and tail, but it'd be useful to see how they compare for other types of operation.

@nicolasstucki
Copy link
Contributor Author

We should benchmark both the compilation time and runtime

@liufengyun
Copy link
Contributor

The regressional benchmark is still running (begins from last November, with one test every 5 PR merges):

http://dotty-bench.epfl.ch/ (at the bottom)

Once it finishes, we will be able to locate to the specific PR that causes the 2x slow down for generic tuples.

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 18, 2019
Improves the state of scala#6524.

Instead of convering all tuples to arrays and performing the operations on them,
we take advantage of the fact that those Tuples are products and have productIterators.
Implementations of tail, *: and ++ on iterators do not require extra collentions to be created,
hence it is also probably more performant at runtime.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 18, 2019
Improves the state of scala#6524.

Instead of convering all tuples to arrays and performing the operations on them,
we take advantage of the fact that those Tuples are products and have productIterators.
Implementations of tail, *: and ++ on iterators do not require extra collentions to be created,
hence it is also probably more performant at runtime.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 18, 2019
Improves the state of scala#6524.

Instead of convering all tuples to arrays and performing the operations on them,
we take advantage of the fact that those Tuples are products and have productIterators.
Implementations of tail, *: and ++ on iterators do not require extra collentions to be created,
hence it is also probably more performant at runtime.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue May 27, 2019
Improves the state of scala#6524.

Instead of convering all tuples to arrays and performing the operations on them,
we take advantage of the fact that those Tuples are products and have productIterators.
Implementations of tail, *: and ++ on iterators do not require extra collentions to be created,
hence it is also probably more performant at runtime.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Jun 5, 2019
Improves the state of scala#6524.

Instead of convering all tuples to arrays and performing the operations on them,
we take advantage of the fact that those Tuples are products and have productIterators.
Implementations of tail, *: and ++ on iterators do not require extra collentions to be created,
hence it is also probably more performant at runtime.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants