Closed scohen closed 1 month ago
@zachallaun can you please respond to the comments?
@scohen I was having a hard time articulating my thoughts on the proxy state stuff, so I went ahead and implemented two changes that I think help to simplify things. They could be taken individually (with some changes), so I'd recommend looking at the two commits separately:
https://github.com/lexical-lsp/lexical/compare/api-proxy...zachallaun:lexical:za-api-proxy?expand=1
To summarize my exploration today, I found that removing Build.with_lock
indeed avoids the deadlock issue. However, occasionally the formatter fails to recognize .formatter.exs. I'm not sure if it's because my commit is missing something.
Additionally, I tried integrating this PR with the Rename module branch, and I found that the renaming can be completed instantly. However, we can't avoid a series of mix compile
commands queuing up, which puts a heavy load on the CPU. The current Rename PR does not compile even once before the renaming is completed.
@scohen I hope you can take a look at this commit when you have time; maybe I'm using the API.Proxy method incorrectly.
@scottming removing the locks is the likely cause for the queueing you’re seeing. That’s not the correct path forward
When doing complicated refactors, the language server will often spam remote_control with a ton of operations when the refactor is going on. These operations will slow down both the editor and remote_control so that it's not particularly usable. In order to mitigate this, certain operations, like project compilation, can be buffered and completed when the refactor has completed.
This PR implements a proxy module that buffers these complicated operations, and monitors the calling process. When that process exits, the buffered operations are emitted in remote_control, allowing them to complete without disrupting the refactor.