Open findleyr opened 1 month ago
Similar Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
I'm responsible for a system that generates a lot of rpc automated code that exists as a remote package that is slow to load and slow to compile. I'm currently working on a GoPackageDriver to automatically generate the code locally at the user's site, which would help a lot if the speed could be increased. ❤️
This issue aggregates some work I'd like to do to refine the
go/packages.Load
calls made by gopls. Generally speaking, these fall into the category of "using gopls' knowledge of the workspace state to refine loading patterns". This should benefit users across the board, but may in particular help for users of go/packages drivers that have different performance characteristics than the go command.A word on terminology: we refer to the packages data returned by
go/packages.Load
as package metadata.Considering only the simple case of a module workspace, metadata loading works approximately as follows (some edge cases are ignored). All loads are inclusive of
-deps
.<modulePath>/...
file=
query (but keep track of files that can't be loaded so we don't keep trying).This loading pattern evolved to ensure we don't miss metadata changes, and can operate on a file as soon as possible. Notably, it was only chosen based on the go command behavior, and generally works because
go list
is heavily optimized. Even loading a relatively large project such as Kubernetes takes only a few seconds.However, there are some improvements to be desired:
-deps
when we're just selectively reloading a file or package. We can theoretically instead load without-deps
, see which imports (if any) are missing, and then load those missing imports in a second pass.<modulePath>/...
.We should experiment with these improvements. I believe they should be of particular help for users of a bazel go/packages drivers, as bazel queries have significantly higher overhead than the go command.
CC @adonovan @JamyDev