Skip to content

Avoid creating most trees in GenBCode #3085

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 1 commit into from
Sep 8, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Sep 7, 2017

GenBCode generates trees when it desugars Idents based on their type.
We now cache the generated tree, avoiding generating the same tree several times.

In the Dotty bootstrap, this reduced generated trees in backend from 606K (about 20%
of total) to 49K.

GenBCode generates trees when it desugars Idents based on their type.
We now cache the generated tree, avoiding generating the same tree several times.

In the Dotty bootstrap, this reduced generated trees in backend from 606K (about 20%
of total) to 49K.
@odersky
Copy link
Contributor Author

odersky commented Sep 7, 2017

test performance please

@dottybot
Copy link
Member

dottybot commented Sep 7, 2017

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

@dottybot
Copy link
Member

dottybot commented Sep 7, 2017

Performance test finished successfully:

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

Benchmarks is based on merge(s) with master

@nicolasstucki
Copy link
Contributor

LGTM

@smarter
Copy link
Member

smarter commented Sep 7, 2017

There is already code that attempts to cache the output of desugarIdent: https://github.com/dotty-staging/dotty/blob/6e6df180d46774651bea43a443f9d074020f68df/compiler/src/dotty/tools/backend/jvm/DottyBackendInterface.scala#L922-L926 With the cache you added, it should now be redundant. I'm also wondering if the added cache could cause memory leaks in the IDE.

@lrytz
Copy link
Member

lrytz commented Sep 7, 2017

Curious: is that something that affects scalac too? Where does GenBCode generate trees?

@odersky
Copy link
Contributor Author

odersky commented Sep 8, 2017

@smarter The thing you are seeing is just a single element cache to support name-based pattern matching. I think it could indeed be eliminated.

I don't think we'll have a problem with space leaks because DottyBackendInterface is re-created for each run.

@lrytz The trees get created because dotc can represent paths with simple Ident nodes (the precise info is in the type of the ident, which is a TermRef). So I don't think this affects scalac.

@odersky
Copy link
Contributor Author

odersky commented Sep 8, 2017

Unfortunately it looks like our tests are still too noisy to be able to tell with confidence whether a change helps or not. It would be good to also use the scalac infrastructure for comparison.

@odersky
Copy link
Contributor Author

odersky commented Sep 8, 2017

@smarter It turns out the desugared field in the Select object of DottybackendInterface is not just a cache but core to the way values are deconstructed. Changing it would require major surgery.

@odersky odersky merged commit a60b9cd into scala:master Sep 8, 2017
@allanrenucci allanrenucci deleted the optimize-trees-1 branch December 14, 2017 19:24
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.

5 participants