Skip to content
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

Zinc extract used names is very sluggish #187

Closed
wants to merge 5 commits into from

Conversation

wpopielarski
Copy link
Contributor

Compilation of shapeless with Zinc is very slow. Potential reason lays in
multiple visit in already traversed tree.

Please look at least at test. This file should be processed in about 5 sec. but actually takes about 5 mins.

@wpopielarski wpopielarski force-pushed the zinc-performance branch 2 times, most recently from c0dee50 to 2ff883f Compare October 21, 2016 13:19
@wpopielarski wpopielarski changed the title [WIP] Zinc extract used names is very sluggish Zinc extract used names is very sluggish Oct 21, 2016
Compilation of shapeless with Zinc is very slow. Potential reason lays in
multiple visit in already traversed tree.
override def traverse(tree: Tree): Unit = {
if (!inspectedTrees.contains(tree)) {
if (handleTree(tree))
inspectedTrees += tree
super.traverse(tree)
Copy link
Member

Choose a reason for hiding this comment

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

Does this handle macro expansion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry @eed3si9n it's not. Going to fix. Looks like there is no test to discover it.

@retronym
Copy link
Member

I would suggest to incorporate sbt/sbt#2754 into Zinc (I've lodged typesafehub/zinc#105 to track this work). When I profiled the slowness of Shapeless with SBT + Scala 2.12, I initially was looking at ways to optimize name extraction but eventually found out that the slowness was (mostly) due to the poor interaction with JIT.

@retronym
Copy link
Member

retronym commented Nov 10, 2016

Actually, I see now that 33e9a50 appears to introduce exponential performance by (accidentally?) introducing tt.original.foreach(traverse) instead of tt.original.foreach(handleNode). Deeply nested ASTs in TypeTree#original (as you would see in long HLists types) will lead you into the problem.

AFAICT, this problem is only introduces in sbt/zinc, not in the incremental compiler in SBT 0.13.x

@retronym retronym mentioned this pull request Nov 10, 2016
20 tasks
@eed3si9n
Copy link
Member

@retronym Thanks for the detective work.

@eed3si9n
Copy link
Member

I opened #193 as a replacement for this PR.

@wpopielarski
Copy link
Contributor Author

superseded by #193

eed3si9n added a commit to eed3si9n/scala that referenced this pull request May 14, 2019
lrytz pushed a commit to lrytz/scala that referenced this pull request Nov 5, 2019
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.

3 participants