Skip to content
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: unimported completions do a lot of work #37183

Closed
muirdm opened this issue Feb 12, 2020 · 2 comments
Closed

x/tools/gopls: unimported completions do a lot of work #37183

muirdm opened this issue Feb 12, 2020 · 2 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@muirdm
Copy link

muirdm commented Feb 12, 2020

I noticed unimported completions were adding 30ms latency to every completion request via imports.GetAllCandidates. It seems to be mostly from allocations:

filepath.Join in findPackage
path.Join in canonicalize
filepath.Rel in canUse
strconv.Atoi in ImportPathToAssumedName (perhaps due to error allocation)

There is also an ioutil.ReadDir call in findPackage that gets called hundreds of time. It was trying to read non-existent directories in the module cache that do exist for different versions of the module.

Maybe the easiest thing is to offer some way to disable unimported package name candidates, leaving unimported package member candidates. That way we wouldn't call GetAllCandidates at all most of the time. I know we don't want config option bloat, though.

Maybe another option is to have a very coarse cache of the result of imports.GetAllCandidates that gets busted whenever any watched file event comes? It's weird that everything is mostly cached already but we still do some much work every time.

/cc @heschik

@gopherbot gopherbot added this to the Unreleased milestone Feb 12, 2020
@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Feb 12, 2020
@gopherbot
Copy link

Thank you for filing a gopls issue! Please take a look at the Troubleshooting guide, and make sure that you have provided all of the relevant information here.

@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Feb 12, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v1.0.0 Feb 13, 2020
@stamblerre stamblerre modified the milestones: gopls/v1.0.0, gopls/v0.4.0 Mar 12, 2020
@stamblerre stamblerre modified the milestones: gopls/v0.4.0, gopls/v0.5.0 Apr 2, 2020
@stamblerre stamblerre removed this from the gopls/v0.5.0 milestone Jun 24, 2020
@stamblerre stamblerre added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 23, 2020
@muirdm
Copy link
Author

muirdm commented Aug 2, 2020

Closing - this doesn't seem to be an issue anymore.

@muirdm muirdm closed this as completed Aug 2, 2020
@stamblerre stamblerre added this to the gopls/v.0.4.5 milestone Aug 4, 2020
@golang golang locked and limited conversation to collaborators Aug 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants