Skip to content

Conversation

@milessabin
Copy link
Contributor

As reported here, #6530 causes a significant slowdown when performing implicit searches for large types: in the case of the "select from large hlist" benchmark it roughly doubles the compile time.

This PR claws almost all of that back by avoiding allocations when traversing through TypeRefs.

@milessabin milessabin added the performance the need for speed. usually compiler performance, sometimes runtime performance. label Aug 7, 2018
@milessabin milessabin added this to the 2.13.0-M5 milestone Aug 7, 2018
@milessabin milessabin requested a review from adriaanm August 7, 2018 22:50
case TypeRef(pre, sym, args) =>
val coreArgs = args.mapConserve(core)
if (coreArgs eq args) tp
else typeRef(pre, sym, coreArgs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would tp.mapOver(this) also do the trick?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might if core was reworked as a TypeMap, but I don't think that would be right here. In particular mapOver also transforms the prefix which I don't think we want to do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mapping over the prefix increases the compile time for the benchmark from 25s to 35s on my machine, so I'd say that's a definite no.

@adriaanm adriaanm merged commit 7cecbdb into scala:2.13.x Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance the need for speed. usually compiler performance, sometimes runtime performance.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants