Skip to content

Cache AnnotatedTypes #9743

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

Merged
merged 2 commits into from
Sep 8, 2020
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Sep 7, 2020

This leads to an increase of cachable applied types. For typer/*.scala:

   cached applied types      uncached applied types
now   32.3K                    0.4K
was   30k                     12.4K

This leads to an increase of cachable applied types. For typer/*.scala:

   cached applied types      uncached applied types
now   32.3K                    0.4K
was   30k                     12.4K

# Conflicts:
#	compiler/src/dotty/tools/dotc/core/Types.scala
Since we are always comparing annotations in AnnotatedTypes with `eq`,
they should always be hashed with identityHashCode.
@smarter
Copy link
Member

smarter commented Sep 7, 2020

Annotations contain a tree whose hash is not stable, how does caching works for them?

@odersky
Copy link
Contributor Author

odersky commented Sep 7, 2020

@smarter Annotations are hashed and compared with identityHashCode and eq.

@smarter
Copy link
Member

smarter commented Sep 7, 2020

Right, but for caching to be useful that means we need to reuse the same tree instance in multiple Annotations, I'm curious in what situation this could happen?

@odersky
Copy link
Contributor Author

odersky commented Sep 7, 2020

I believe the wins are more for types containing annotated types. Previously, since annotated types were not cached any type containing them was not cached either. The numbers in the PR message show this clearly: We go from 42.4k AppliedTypes to
32.7k. Even for annotated types it's relevant. Say we do an asSeenFrom on an annotated type. Now, if the parent part produces a type that we have seen already, we can cache it.

@odersky
Copy link
Contributor Author

odersky commented Sep 7, 2020

test performance please

@dottybot
Copy link
Member

dottybot commented Sep 7, 2020

performance test scheduled: 3 job(s) in queue, 1 running.

@dottybot
Copy link
Member

dottybot commented Sep 7, 2020

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/9743/ to see the changes.

Benchmarks is based on merging with master (101e620)

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

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

LGTM

@odersky odersky merged commit a1deca9 into scala:master Sep 8, 2020
@odersky odersky deleted the cache-annotated-types branch September 8, 2020 11:41
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.

4 participants