Skip to content

Speed up the autocomplete and filter feature. #2889

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

Closed
Kidsunbo opened this issue Jul 26, 2023 · 8 comments
Closed

Speed up the autocomplete and filter feature. #2889

Kidsunbo opened this issue Jul 26, 2023 · 8 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@Kidsunbo
Copy link

Is your feature request related to a problem? Please describe.
For some small projects, everything works fine and smoothly. But for some projects which contains big files with more than 150,000 loc. The autocomplete and filter when typing works but extreme slow. For the same project, GoLand and NeoVim with gopls all takes one second to give the sugguestion. But with VSCode with go extension, it takes more than 4 seconds which is almost intolerant.
Is there a way to speed up such feature?

Describe the solution you'd like
VSCode gives the autocomplete suggestion and filter less than 1 seconds for structs from big package. Just like GoLand and NeoVim do.

Describe alternatives you've considered
I was thinking it's related to gopls, but I've also tried it with NeoVim, it works fine. For some small project, it gives the autocomplete much faster than that in big project.

Additional context
I notice that in GoLand, the autocomplete starts from few suggestions and then appended to all suggestion. But in VSCode, it will give out all suggestion at once but it takes some time.

@gopherbot gopherbot added this to the Untriaged milestone Jul 26, 2023
@findleyr
Copy link
Member

Thanks for testing in neovim. Are any of the projects you experience this with open source?

We should confirm the latency distribution of completion handling. Can you start gopls with -debug=localhost:6060 and visit http://localhost:6060/trace/? Look for 'completion' and share the latency numbers there.

Another possibility is that completion is backed-up behind another request. RPC logs would tell that story, but are harder to read (and not safe to share if the project is private).

Do you have any custom settings? In particular "completionBudget"?

@Kidsunbo
Copy link
Author

Kidsunbo commented Jul 27, 2023

Thanks for testing in neovim. Are any of the projects you experience this with open source?

We should confirm the latency distribution of completion handling. Can you start gopls with -debug=localhost:6060 and visit http://localhost:6060/trace/? Look for 'completion' and share the latency numbers there.

Another possibility is that completion is backed-up behind another request. RPC logs would tell that story, but are harder to read (and not safe to share if the project is private).

Do you have any custom settings? In particular "completionBudget"?

For the open source project ( I only test K8S, which is big I think) , VSCode works fine. I guess it might be caused by some big source file generated by thrift in my private project.
image

image

And sorry for the RPC logs because the code belongs to my Company :(.
I haven't change any settings. All the setting is default.

@hyangah hyangah modified the milestones: Untriaged, vscode-go/later Jul 27, 2023
@hyangah hyangah added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 27, 2023
@khanakia
Copy link

khanakia commented Sep 6, 2023

I am having the same issue.
@Kidsunbo can you guide how do i start gopl in debug mode in vscode ?

@Kidsunbo
Copy link
Author

Kidsunbo commented Sep 6, 2023

I am having the same issue. @Kidsunbo can you guide how do i start gopl in debug mode in vscode ?

I can't quite remember the actual steps I did. But I think I was just following the steps in this document. https://go.googlesource.com/tools/+/refs/tags/gopls/v0.4.2-pre1/gopls/doc/troubleshooting.md

type this in the settings.json

"go.languageServerFlags": [
  "serve",
  "-rpc.trace",
  "--debug=localhost:6060",
],

and fetch the debug info with url in the setting.

In addition, I partly solve this problem by updating gopls to latest version in which they fix the OOM issue and disabling the lint like staticcheck, golangci-lint and something like those.

I don't think vscode-go can do much about the parsing speed because that's gopls's bussiness. In Goland it's much faster, but I think it's due to the Language Parser used by Goland is a little better.

I also compare the action taken by vscode-go and Goland, I notice that even in Goland, it still stucks a little if the package is extremely large. But in Goland, it shows something first, and then add the rest in one or two seconds. With vscode-go, everything shows up at once, so the feeling will be different even though both take the same time.

@findleyr
Copy link
Member

findleyr commented Sep 6, 2023

Yes, one of the problems we face here is the fact that VS Code does not support streaming auto complete suggestions. So we have to strike a balance between latency and completeness.

@findleyr
Copy link
Member

@Kidsunbo could you try with gopls@master? I believe you may be running into golang/go#/62665, which was just fixed.

To install gopls@master:

git clone go.googlesource.com/tools
cd tools/gopls
go install

@findleyr findleyr added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Sep 28, 2023
@Kidsunbo
Copy link
Author

@Kidsunbo could you try with gopls@master? I believe you may be running into golang/go#/62665, which was just fixed.

To install gopls@master:

git clone go.googlesource.com/tools
cd tools/gopls
go install

Yes, the speed is much faster than before and it's much enjoyable with the master version. When will it be released? BTW, thank you for the improvement.

@findleyr
Copy link
Member

Thanks for confirming.

I plan to cut a prerelease containing the fix tomorrow or Monday, with a full release in a few weeks.

@golang golang locked and limited conversation to collaborators Sep 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants