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: feature request: option to go list to not sort output #23803
Comments
I think the actual sort is pretty far from cmd/go; I think it's the sort done by But I'm not sure I believe that the sort takes 4 seconds. As you suggest, the sort time is likely negligible. It's more likely the fact that the go tool collects all the packages together, and then lists them. |
just grepping around I found a bunch of calls to sort in internal/load which the list subcommand uses, but didn't think about filepath.Walk. It appears to use that as well. I'm sure it would be a large change for a niche use case but figured it's better to file than not. |
@jimmyfrasche it would be useful if you could get some metrics for large package sets (such as I also don't know if it would be possible for |
/cc @rsc who has designed much of this, and who I think wants to work on |
@mvdan I'll try to gather some metrics later. A fast path for just printing import paths would be helpful. That's the most common use case, at least for me, though when used as such it's usually for smaller package sets, such as to get the import path of the current working directory or something like The particular use case inspiring the bug involves invoking As far as incremental output, the dependency graph is acyclic so theoretically an incremental mode could output leaves immediately and then any packages that only depend on leaf packages and so on up the tree. Maybe it would suffice to be smarter about caching the results (and invalidating the cache)? Warm up would still be slow but it would still tend to be quite fast in most cases. It seems that a lot of go subcommands make use of the internal/load package so optimizing it might make a lot of things faster whenever large package sets are involved:
|
Sorry but I don't think we are going to attempt to stream the results into go list. |
I've been writing programs that exec
go list
to get package names or info with-json
. They often don't care about the ordering of the output and could grab lines or json documents as they come in and start processing.The sorting's not an issue for small requests, but larger ones like
all
orgithub.com/...
can take a bit (approximately 4s with my workspace/machine according to bash's time builtin). I realize that the sorting itself is likely negligible but if it output packages as soon as they were done processing I could get to get work processing them while the rest loads.The text was updated successfully, but these errors were encountered: