Skip to content

Cache also private members #9648

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 11 commits into from
Sep 1, 2020
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Aug 26, 2020

Keep private members in member caches as well.
This means we have to do extra work for a nonPrivateMember call
that hits a private member. But that's probably not a very
common case. On the other hand, every regular findMember operation
needs one less scope lookup this way.

Use a full cache instead of an LRU cache. For `typer/*.scala`, this
reduced computed member searches on normal ClassDenotations from 520K to
170K. Cache hit rate improves to 97.5%, from 92.5%. (Without member caching
there are almost 7Mio computed members for the same code base).
The two implementation classes of LinearTable had so much in common that
they could be combined. Since the implementation is now fixed, we can
use the usual mutable interface for a table.
When going from dense to hashed, we should expand by a multiple greater
than two, or we will have to reallocate immediately afterwards.
We get occasional failures of the form

java.lang.AssertionError: assertion failed: asTerm called on not-a-Term val <none> while compiling tests/pos/projections.scala
Fatal compiler crash when compiling: tests/pos/projections.scala:
assertion failed: asTerm called on not-a-Term val <none>
dotty.DottyPredef$.assertFail(DottyPredef.scala:17)
dotty.tools.dotc.core.Symbols$Symbol.asTerm(Symbols.scala:156)

when compiling pos/projections.scala with FromTasty tests.

It was first observed when we parallelized position pickling, so it might have something to do with that.
NoDenotation is a frequent result, so we should keep post processing
it as simple as possible.

As a side effect this now forces less, which makes some previously failing tests
pass. I updated i3253.scala so that it fails again and moved i9052 to pos.
This means we have to do extra work for a nonPrivateMember
that hits a private member. But that's probably not a very
common case. On the other hand, every find member operation
needs one less scope lookup this way.
@odersky odersky force-pushed the private-member-caching branch from 2bdee9e to 44a07d6 Compare August 26, 2020 18:21
@odersky
Copy link
Contributor Author

odersky commented Aug 26, 2020

test performance please

@dottybot
Copy link
Member

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

@dottybot
Copy link
Member

Performance test finished successfully:

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

Benchmarks is based on merging with master (2e58a66)

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.

myMemberCache is not copied when we create a new ClassDenotation from an existing one (See copyCaches). I assume that is OK, as when we copy a ClassDenotation, usually its member cache becomes invalid.

Co-authored-by: Fengyun Liu <liu@fengy.me>
@odersky
Copy link
Contributor Author

odersky commented Sep 1, 2020

Yes, not copying member caches is intentional since then we do not have to worry about validity.

@odersky odersky merged commit 5a0cbb9 into scala:master Sep 1, 2020
@odersky odersky deleted the private-member-caching branch September 1, 2020 12:27
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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