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

Improve performance of BSP classpath retrieval #1794

Closed
wants to merge 4 commits into from

Conversation

abernardi597
Copy link

Issue reported in #1792

@lefou
Copy link
Member

lefou commented Mar 24, 2022

In #1793 I already applied your suggested fix and also added a test case. It would be nice, if we can rebase this PR after #1793 is merged.

I don't know how hard it would be to add a test case that shows the time spent in the (inefficient) module traversal (mentioned in #1792) in bspCompileClasspath, but it would be great to have a test which reproduces such a setup to make sure we perform good enough. The easiest way to produce a huge amount of modules is by creating a Cross module and have lots of instances.

@lefou
Copy link
Member

lefou commented Mar 25, 2022

I applied this test case #1792 (comment) and here is the output.

You can see it behaves better than before, e.g. no out of memory exception and shorter time spans, but still once the modules count with inter-dependencies goes up, there is a huge increase in runtime.

-------------------------------- Running Tests --------------------------------
mill.scalalib.bsp.BspModuleTests: [13/14] HelloBsp.resolvedIvyDeps 
mill.scalalib.bsp.BspModuleTests: [21/22] HelloBsp2.resolvedIvyDeps 
+ mill.scalalib.bsp.BspModuleTests.bspCompileClasspath.single module.dependent module 1727ms  
mill.scalalib.bsp.BspModuleTests: [13/14] HelloBsp.resolvedIvyDeps 
mill.scalalib.bsp.BspModuleTests: [13/14] Mod[1].resolvedIvyDeps 
+ mill.scalalib.bsp.BspModuleTests.bspCompileClasspath.single module.interdependencies are fast.index 1 (no deps) 316ms  137 msec
mill.scalalib.bsp.BspModuleTests: [13/14] HelloBsp.resolvedIvyDeps 
mill.scalalib.bsp.BspModuleTests: [85/86] Mod[10].resolvedIvyDeps 
+ mill.scalalib.bsp.BspModuleTests.bspCompileClasspath.single module.interdependencies are fast.index 10 678ms  515 msec
mill.scalalib.bsp.BspModuleTests: [13/14] HelloBsp.resolvedIvyDeps 
mill.scalalib.bsp.BspModuleTests: [165/166] Mod[20].resolvedIvyDeps 
+ mill.scalalib.bsp.BspModuleTests.bspCompileClasspath.single module.interdependencies are fast.index 20 845ms  717 msec
mill.scalalib.bsp.BspModuleTests: [13/14] HelloBsp.resolvedIvyDeps 
mill.scalalib.bsp.BspModuleTests: [245/246] Mod[30].resolvedIvyDeps 
X mill.scalalib.bsp.BspModuleTests.bspCompileClasspath.single module.interdependencies are fast.index 30 29498ms 
  utest.AssertionError: assert(timeSpent < 5000)
  timeSpent: Long = 29384
    utest.asserts.Asserts$.assertImpl(Asserts.scala:30)
    mill.scalalib.bsp.BspModuleTests$.$anonfun$tests$22(BspModuleTests.scala:112)
    mill.scalalib.bsp.BspModuleTests$.workspaceTest(BspModuleTests.scala:51)
    mill.scalalib.bsp.BspModuleTests$.run$1(BspModuleTests.scala:54)
    mill.scalalib.bsp.BspModuleTests$.$anonfun$tests$29(BspModuleTests.scala:119)
mill.scalalib.bsp.BspModuleTests: [13/14] HelloBsp.resolvedIvyDeps 
^C

Copy link
Member

@lefou lefou left a comment

Choose a reason for hiding this comment

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

Thank you for your pull request. In the meantime I came up with a test cases which shows these performance issue. The current logic is heavily using T.task as it depends on some non-static details from the current evaluator. But I think I've come up with another idea, how we can avoid all these ad-hoc and un-cached tasks and replace it with more granular cached targets. I'll open a PR once I have implemented it.

Even if that means, that we won't merge your PR, your work is much appreciated! It helped greatly to understand the issue and gave food for thoughts.

@abernardi597
Copy link
Author

No problem, thanks for taking a look at this!
I'll keep an eye out for your other idea, since I'm interested in the cached approach.

@lefou
Copy link
Member

lefou commented Mar 29, 2022

@abernardi597 I opened #1803. I'd love to get your feedback for it.

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.

2 participants