scalacenter / scala-debug-adapter

Implementation of the Debug Adapter Protocol for Scala
Apache License 2.0
59 stars 26 forks source link

Improved Performance of loadClassesByScalaName #727

Closed crt-31 closed 3 months ago

crt-31 commented 3 months ago

Refactored SourceLookUpProvider.loadClassesByScalaName() to be more efficient.

The issue presented itself in 4.0.0 (related to the HotCodeReplace feature). The debug loading times became really slow.

On my large project, the loading went from 75s back to a normal 12s. (12s is about what I saw in v3.1.6).

This should resolve https://github.com/scalameta/metals/issues/6544

adpi2 commented 3 months ago

Thanks for your contribution @crt-31

Using the SourceLookUpProviderStats we can clearly see the speedup:

Before After
ubuntu-latest 1510 ms 830 ms
windows-latest 2299 ms 1297 ms
macOS-latest 1682 ms 633 ms

I also wonder if we could make it even faster using a mutable.Map.

adpi2 commented 3 months ago

I am going to release this asap.

@crt-31 thanks again! Feel free to open new pull requests if you see any other hot spot :)