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

Comments

@muirdm
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
@gopherbot gopherbot added the Tools label Feb 12, 2020
@gopherbot
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.

@gopherbot gopherbot added the 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
@muirdm
Copy link
Author

@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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.