-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/go: avoid work to compute unused fields in 'go list' #29666
Comments
From what I can piece together, Hana's example above is particularly poor, but probably unfixable. It's looking for a v1 module, but it needs to download every non-v1 version too to make sure that they all have a go.mod. (If one didn't, then it'd be +incompatible and a valid answer for the query.) Previously we had been looking at the way it behaves when fetching rsc.io/quote/v2, or a v1 module from a repo that doesn't have v2 yet. That can probably be improved. |
I would rather do the field-based pruning than add a separate flag. Field-based pruning gives us the opportunity to eliminate a lot of different kinds of redundant work, whereas a “skip timestamp fetching” flag would have a very narrow benefit. |
One nice option for the JSON field-pruning might be to allow the
|
It occurs to me that this could interact with caching in an interesting way: if you're only looking for new versions and you know when you last checked the repo, then it's probably safe to assume that any tag that was |
I really like the idea of |
Retitled to address the general problem: we won't be adding a specific flag to avoid VCS fetches, but we certainly can optimize the work that we do based on the requested output. |
In CL 270858, we noticed that |
Change https://golang.org/cl/309190 mentions this issue: |
Change https://golang.org/cl/309191 mentions this issue: |
…the name of the main module For #36460 For #29666 Change-Id: I9e46f7054d52c053be80c483757cdd34b22822d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/309190 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Jay Conrod <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
…ting specific modules For #36460 For #41297 Updates #29666 Change-Id: I5f324c0ef9a164f8043d2188101d141bb5fa7454 Reviewed-on: https://go-review.googlesource.com/c/go/+/309191 Trust: Bryan C. Mills <[email protected]> Run-TryBot: Bryan C. Mills <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Jay Conrod <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
If the user provides the -json flag to explicitly specify fields, but doesn't specify the Deps or DepsErrors fields, skip computing the deps fields. For #29666 Change-Id: I15596c374aba1af13bdf5808d11d54abdc838667 Reviewed-on: https://go-review.googlesource.com/c/go/+/392495 Reviewed-by: Bryan Mills <[email protected]> Run-TryBot: Michael Matloob <[email protected]> Auto-Submit: Michael Matloob <[email protected]> Reviewed-by: Michael Matloob <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
Change https://go.dev/cl/402736 mentions this issue: |
The only fields of the go list output that require BuildInfo to be computed are the Stale and StaleReason fields. If a user explicitly requests JSON fields and does not ask for Stale or StaleReason, skip the computation of BuildInfo. For #29666 Change-Id: Ie77581c44babedcb5cb7f3dc7d6ed1078b56eee4 Reviewed-on: https://go-review.googlesource.com/c/go/+/402736 Run-TryBot: Michael Matloob <[email protected]> Reviewed-by: Michael Matloob <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Michael Matloob <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
Change https://go.dev/cl/417595 mentions this issue: |
For #29666. Change-Id: I575375fb039e5809b0ed2ce985f6352a61142d63 Reviewed-on: https://go-review.googlesource.com/c/go/+/417595 TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]> Run-TryBot: Bryan Mills <[email protected]>
For golang#29666. Change-Id: I575375fb039e5809b0ed2ce985f6352a61142d63 Reviewed-on: https://go-review.googlesource.com/c/go/+/417595 TryBot-Result: Gopher Robot <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Hyang-Ah Hana Kim <[email protected]> Run-TryBot: Bryan Mills <[email protected]>
Closing this issue as the -json=SomeField feature has been released in Go 1.19 |
If the user provides the -json flag to explicitly specify fields, but doesn't specify any *Embed* field, skip computing the embed fields. This enhances the initial implementation of golang#29666.
If the user provides the -json flag to explicitly specify fields, but doesn't specify any *Embed* field, skip computing the embed fields. This enhances the initial implementation of golang#29666.
The `-json` option allows specifying a comma separated list of property names to include in the output. The `go list` command has a mechanism for skipping certain processing steps which are not needed for computing the values corresponding to those specified property names, see [^1],[^2] and [^3]. Such a mechanism is not in place for the `-f` option. Migrate from `-f` to `-json` to benefit from above mechanism, removing potential sources of issues. It could be that this allows to drop the parameter `-buildvcs=false`, which is left for future investigation. The primary reason for switching to `-json` is to extend the mentioned mechanism [^4]] in `go list` to conditionally skip computing embed files in an analog way which would fix [^5]. [^1]: https://github.com/golang/go/blob/0cd309e12818f988693bf8e4d9f1453331dcf9f2/src/cmd/go/internal/load/pkg.go#L2768-L2776 [^2]: https://github.com/golang/go/blob/0cd309e12818f988693bf8e4d9f1453331dcf9f2/src/cmd/go/internal/list/list.go#L605-L606 [^3]: golang/go#29666 [^4]: golang/go#49534 (comment) [^5]: #5560 Signed-off-by: Frank Viernau <[email protected]>
Change https://go.dev/cl/468075 mentions this issue: |
If the user provides the -json flag to explicitly specify fields, but doesn't specify any *Embed* field, skip computing the embed fields. This enhances the initial implementation of golang#29666.
If the user provides the -json flag to explicitly specify fields, but doesn't specify any *Embed* field, skip computing the embed fields. This enhances the initial implementation of golang#29666.
If the user provides the -json flag to explicitly specify fields, but doesn't specify any *Embed* field, skip computing the embed fields. This enhances the initial implementation of golang#29666.
The `-json` option allows specifying a comma separated list of property names to include in the output. The `go list` command has a mechanism for skipping certain processing steps which are not needed for computing the values corresponding to those specified property names, see [^1],[^2] and [^3]. Such a mechanism is not in place for the `-f` option. Migrate from `-f` to `-json` to benefit from above mechanism, removing potential sources of issues. It could be that this allows to drop the parameter `-buildvcs=false`, which is left for future investigation. The primary reason for switching to `-json` is to extend the mentioned mechanism [^4] in `go list` to conditionally skip computing embed files in an analog way which would fix [^5]. [^1]: https://github.com/golang/go/blob/0cd309e12818f988693bf8e4d9f1453331dcf9f2/src/cmd/go/internal/load/pkg.go#L2768-L2776 [^2]: https://github.com/golang/go/blob/0cd309e12818f988693bf8e4d9f1453331dcf9f2/src/cmd/go/internal/list/list.go#L605-L606 [^3]: golang/go#29666 [^4]: golang/go#49534 (comment) [^5]: #5560 Signed-off-by: Frank Viernau <[email protected]>
The `-json` option allows specifying a comma separated list of property names to include in the output. The `go list` command has a mechanism for skipping certain processing steps which are not needed for computing the values corresponding to those specified property names, see [^1],[^2] and [^3]. Such a mechanism is not in place for the `-f` option. Migrate from `-f` to `-json` to benefit from above mechanism, removing potential sources of issues. It could be that this allows to drop the parameter `-buildvcs=false`, which is left for future investigation. The primary reason for switching to `-json` is to extend the mentioned mechanism [^4] in `go list` to conditionally skip computing embed files in an analog way which would fix [^5]. [^1]: https://github.com/golang/go/blob/0cd309e12818f988693bf8e4d9f1453331dcf9f2/src/cmd/go/internal/load/pkg.go#L2768-L2776 [^2]: https://github.com/golang/go/blob/0cd309e12818f988693bf8e4d9f1453331dcf9f2/src/cmd/go/internal/list/list.go#L605-L606 [^3]: golang/go#29666 [^4]: golang/go#49534 (comment) [^5]: #5560 Signed-off-by: Frank Viernau <[email protected]>
The `-json` option allows specifying a comma separated list of property names to include in the output. The `go list` command has a mechanism for skipping certain processing steps which are not needed for computing the values corresponding to those specified property names, see [^1],[^2] and [^3]. Such a mechanism is not in place for the `-f` option. Migrate from `-f` to `-json` to benefit from above mechanism, removing potential sources of issues. It could be that this allows to drop the parameter `-buildvcs=false`, which is left for future investigation. The primary reason for switching to `-json` is to extend the mentioned mechanism [^4] in `go list` to conditionally skip computing embed files in an analog way which would fix [^5]. [^1]: https://github.com/golang/go/blob/0cd309e12818f988693bf8e4d9f1453331dcf9f2/src/cmd/go/internal/load/pkg.go#L2768-L2776 [^2]: https://github.com/golang/go/blob/0cd309e12818f988693bf8e4d9f1453331dcf9f2/src/cmd/go/internal/list/list.go#L605-L606 [^3]: golang/go#29666 [^4]: golang/go#49534 (comment) [^5]: #5560 Signed-off-by: Frank Viernau <[email protected]>
The `-json` option allows specifying a comma separated list of property names to include in the output. The `go list` command has a mechanism for skipping certain processing steps which are not needed for computing the values corresponding to those specified property names, see [^1],[^2] and [^3]. Such a mechanism is not in place for the `-f` option. Migrate from `-f` to `-json` to benefit from above mechanism, removing potential sources of issues. It could be that this allows to drop the parameter `-buildvcs=false`, which is left for future investigation. The primary reason for switching to `-json` is to extend the mentioned mechanism [^4] in `go list` to conditionally skip computing embed files in an analog way which would fix [^5]. [^1]: https://github.com/golang/go/blob/0cd309e12818f988693bf8e4d9f1453331dcf9f2/src/cmd/go/internal/load/pkg.go#L2768-L2776 [^2]: https://github.com/golang/go/blob/0cd309e12818f988693bf8e4d9f1453331dcf9f2/src/cmd/go/internal/list/list.go#L605-L606 [^3]: golang/go#29666 [^4]: golang/go#49534 (comment) [^5]: #5560 Signed-off-by: Frank Viernau <[email protected]>
If the user provides the -json flag to explicitly specify fields, but doesn't specify any *Embed* field, skip computing the embed fields. This enhances the initial implementation of golang#29666.
If the user provides the -json flag to explicitly specify fields, but doesn't specify any *Embed* field, skip computing the embed fields. This enhances the initial implementation of #29666. Change-Id: I60e86fb25a445689aecbcc7f3f3f88e0f37a0fc5 GitHub-Last-Rev: 2795c19 GitHub-Pull-Request: #58522 Reviewed-on: https://go-review.googlesource.com/c/go/+/468075 Reviewed-by: Bryan Mills <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Auto-Submit: Bryan Mills <[email protected]>
We want to get the list of available versions of a module
and the best way is to use
go list -m --versions <module>
.Under the hood, the command retrieves the tag list (which we expected)
and also fetches some versions (which is surprising).
Our guess is that the
go list
does so in order to find informationlike the latest version's commit time, etc. For our use case, we don't need
that information and the extra fetch slows down the go list especially
when the repository is large.
Can we have a flag to skip the fetch?
An alternative mentioned by @bcmills is to make
go list
smarter so itperforms steps necessary to fill in the requested information (e.g. fields
mentioned in -f, or with an additional option to specify fields to prune if
-json is requested)
@bcmills @heschik @katiehockman @jayconrod
The text was updated successfully, but these errors were encountered: