Don't run compilation on InteractiveDriver.run
every time for the "same input"
#17716
Replies: 7 comments
-
Wasn't me, although I did do something similar some time ago for Scala Native sbt plugin (which, in hindsight, maybe should have been included in the Scala Native itself), where we ended up caching classpath file content hashes and the configuration. Not sure if I can help with this though (no knowledge about the InteractiveDriver) |
Beta Was this translation helpful? Give feedback.
-
Sorry, it was @rochala 😆 |
Beta Was this translation helpful? Give feedback.
-
Yes, indeed I was going (and still I plan on doing it) to look more into this topic, but I didn't have time recently. I'll do this probably next week. |
Beta Was this translation helpful? Give feedback.
-
I also have a problem with this issue. The laptop gets so hot because of it that it burns my fingers. |
Beta Was this translation helpful? Give feedback.
-
We discussed this feature with @rochala, and he built some PoC implementation. Another idea is implementing the InteractiveDriver cache on the Metals side:
|
Beta Was this translation helpful? Give feedback.
-
Hey @rochala I figured out how Scala2 + Metals caches the compilation result, I summarized https://contributors.scala-lang.org/t/how-does-scala2-compiler-cache-invalidate-the-typechecking-result-for-the-given-tree/5858/4 While in Scala2, we skip typechecking if the given tree is already typed, it looks like Scala3 doesn't do such a thing (and it might be a bit complicated to do that). Therefore, I'm going to implement the cache feature in Metals basically the way I described in scalameta/metals#4060 + cache purging on change. Thank you very much for taking a look at this issue from the perspective of the compiler side / discussing it with me! |
Beta Was this translation helpful? Give feedback.
-
End up doing like this scalameta/metals#4225 :) FYI @rochala |
Beta Was this translation helpful? Give feedback.
-
Originally reported in scalameta/metals#4060
TL;DR
InteractiveDriver.run
InteractiveDriver
or its consumers (likemetals
side)?Background
While I CPU profile Metals using async-profiler, I realized that Metals (in Scala3 project) invokes
InteractiveDriver.run
quite frequently, especially fromHoverProvider.hover
(that invokes when users hover on symbol in the editors).This is because we invoke
InteractiveDriver.run
every time when Metals uses information from presentation compilers.For example,
HoverProvider.hover
runsInteractiveDriver.run
for every invocations anyway.https://github.com/scalameta/metals/blob/eab3df81d3a55445f558c959ee5d2fa24308be82/mtags/src/main/scala-3/scala/meta/internal/pc/HoverProvider.scala#L39
It might be a big CPU saver if we don't run
InteractiveDriver.run
if the input is the same (that is likely to happen especially when we're code reading and doing hover or navigations).A little bit of experiments
I tried to experiment, maybe we can cache invalidate by checking the combination of file content and
runId
scalameta/metals#4100However, I realized that this work only if we edit files only in Metals.
We need to know if there are changes on the classpath. 🤔
Questions
InteractiveDriver
aware of, no?InteractiveDriver
side or Metals side? (Or do you think we shouldn't cache it?)Any opinions are welcome!
BTW, I heard that someone is already taking a look at this topic, maybe @jchyb ? (sorry if I mistaken)
Beta Was this translation helpful? Give feedback.
All reactions