Skip to content
This repository has been archived by the owner on Oct 27, 2021. It is now read-only.

Parse files in parallel and only parse buildable files #54

Closed

Conversation

charlievieth
Copy link

@charlievieth charlievieth commented Sep 8, 2018

This commit introduces two changes. The first is to parse other package files in parallel. The second is to only parse files that would be considered buildable by go/build.

Using go/build.Import() is relatively slow and cannot be parallelized (it must run before the parallel parse). To get around using go/build, this commit adds a package 'buildutil', which is a slimmed down version of github.com/charlievieth/buildutil, that can quickly determine if a package should be included. In order for 'buildutil' to respect the PackedContext passed in by the client - it was added as a field to suggest.Config, which is populated by the server.

This commit introduces two changes.  The first is to parse other package
files in parallel.  The second is to only parse files that would be
considered buildable by go/build.

Using go/build.Import() is relatively slow and cannot be parallelized
(it must run before the parallel parse).  To get around using go/build,
this commit adds a package 'buildutil', which is a slimmed down version
of github.com/charlievieth/buildutil, that can quickly determine if a
package should be included.  In order for 'buildutil' to respect the
PackedContext passed in by the client - it was added as a field to
suggest.Config, which is populated by the server.
@charlievieth
Copy link
Author

charlievieth commented Sep 9, 2018

Tests pass on Go versions 1.10.3 and go1.11.0 on Linux and Darwin. Tests also pass on Linux with the latest development version of Go:

go version devel +4545fea4fc Sat Sep 8 23:59:26 2018 +0000 linux/amd64

@charlievieth
Copy link
Author

charlievieth commented Sep 9, 2018

There is a follow on PR to move PackedContext to a separate context package (commit: charlievieth@bbaaca9 - branch) that I will create if this is accepted.

That will make the separation of concerns a little cleaner under the internal directory since PackedContext is now used by the main, gbimporter and suggest packages.

@charlievieth
Copy link
Author

bump

@myitcv
Copy link

myitcv commented Sep 19, 2018

@charlievieth I suspect these changes will be superseded by an upcoming change that is currently being tested out in https://github.com/stamblerre/gocode, namely support for #46.

That support uses the new go/packages.

cc @stamblerre and @matloob

@charlievieth
Copy link
Author

charlievieth commented Sep 25, 2018

SGTM. Let me know if you'd like for me to close this PR (#54) and my other one (#55 - parse files in parallel) since go/packages does that already.

@stamblerre
Copy link
Collaborator

Yeah, I'm sorry about this, but I think it may not be worth it to accept these PRs because of our planned migration to go/packages.

@charlievieth
Copy link
Author

np, happy to close.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants