Improve LSP performance for files that have a lot of cross-file refs
Since removing concurrency from the LSP, performance has degraded substantially. This PR fixes some performance issues by being smart about doing less work. Most of this will be mooted by https://github.com/bufbuild/protocompile/pull/355, but until we have intelligent memoization, we can use some dumb heuristics to improve perf.
First, we don't send progress notifications for files that have not been opened by the client's editor. Hammering the Unix socket with notifications is a major source of slowdown, and these notifications are not useful to the user, because they are about files they do not care about.
Second, we don't send diagnostics for the same. These files get reparsed when opened in the editor regardless, so this doesn't risk staleness.
Third, we were previously reindexing imported files once per cross-file ref. This is clearly an oversight on my part, which I suspect was caused due to nasty merge conflicts on my last PR. I noticed because protovalidate/priv/private.proto was getting hammered in the logs -- all because validate.proto references the priv symbol dozens of times. 🤦
After fixing all of these, the LSP went from sluggish to snappy (in VSCode).
The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).
| Build | Format | Lint | Breaking | Updated (UTC) |
|---|---|---|---|---|
✅ passed | ✅ passed | ✅ passed | ✅ passed | Oct 23, 2024, 4:22 PM |