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

muirdm opened this issue Feb 12, 2020 · 2 comments

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

muirdm opened this issue Feb 12, 2020 · 2 comments


Copy link

@muirdm 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
Copy link

@gopherbot gopherbot commented Feb 12, 2020

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.

@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
Copy link

@muirdm muirdm commented Aug 2, 2020

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

@muirdm muirdm closed this Aug 2, 2020
@stamblerre stamblerre added this to the gopls/v.0.4.5 milestone Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants