-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
x/tools/gopls: add ability to avoid scanning an entire workspace #53278
Comments
Regarding didChange processing time, we're working on landing the stack in #45686 now (for the next release). This should help significantly, though there will still be a fair bit of time spent "inheriting", and unfortunately that cant be avoided without more significant changes to gopls' caching logic. We are going to make those changes, but it will take longer. Assuming you've narrowed your workspace in the go.work, the real problem is that gopls is walking files unnecessary, and that's just a bug. We have a couple open issues related to this also in the v0.9.0 milestone. Would you be willing to try out some experimental patches in your workspace? |
Hi, yeah, I can try them out. I've also made some experiments myself, one thing I've noticed is that a huge chunk of time is spent in copying |
@euroelessar https://go.dev/cl/410176 addresses that point, as a starting point. Sorry, that wasn't linked to the issue. We also have optimizations for Inherit in the works. |
Also: would you be willing to share your implementation? We'd certainly accept a contribution in this area. |
Sure, let me clean it up a bit, will send it later today |
CC @adonovan |
@euroelessar before you spend time cleaning it up, you can share what you have and we can confirm that it meets requirements. There are some non-obvious reasons why we use a reference counted cache, for example sharing results across multiple views / sessions. But there are of course other ways to achieve this. |
Please see golang/tools#382 |
@findleyr does it satisfy the requirements, should I continue investment in the change & make it satisfy the code quality requirements? (like add documentation, fix code style, add typing, etc) based on my experiments the combination of this change (extended to |
@euroelessar, first of all thanks for the time and thought you have put into this. I think there are some nice ideas in your CL, but I haven't had time to do a deep review. I am away this next week. In the meantime, I defer to @adonovan for how to proceed (or we can simply delay a week). |
The GOPATH scan should have been fixed by https://go.dev/cl/413689. I think the other optimizations mentioned here are either complete, or tracked by separate issues. Thanks again for your contributions! |
gopls version
go env
What did you do?
We've recently made an attempt to add
go.work
file to our monorepo.What did you expect to see?
No performance/behavior degradation, only behavior ones (like fetching 3rd party modules via
go mod
instead of relying on their presence inGOPATH
).What did you see instead?
Adding
go.work
file has drastically changed gopls behavior compared to the state before:textDocument/didChange
per-call latency has increased from 2ms to 250ms (given a faulty batching in vscode-go it leads to multi-second delay between finishing typing & getting completion suggestions as it looks like every individual character change is sent via separate event)Based on experiments it looks like before adding
go.work
file gopls did not make an attempt to scan and parse an entireGOPATH
codebase, instead it was parsing only transitive dependencies of opened go files.While I understand that it potentially was not an intended gopls behavior, but are you open to return it via an additional opt-in option? Without that gopls in current state is not usable on a repository of the given size.
Based on my limited knowledge it can be achieved by short-circuting
(*snapshot).loadWorkspace
logic.Note, I've also tried to set
memoryMode
toDegradeClosed
and while it reduces memory usage considerably (from 20GB to 2GB) it unfortunately does not improvetextDocument/didChange
latency.Somehow side-tracking,
textDocument/didChange
spends mostly all of its time in copying the snapshot, which runtime complexity (as was discussed in other issues) can likely be optimized by using persistent data structures. Are you open for changes in that area? If so, what channel can be used to discuss the details and potential avenues for it (like slack?)?Editor and settings
Logs
The text was updated successfully, but these errors were encountered: