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/cmd/guru: limit 'referrers' query to scope? #14747

Open
dominikh opened this issue Mar 10, 2016 · 8 comments
Open

x/tools/cmd/guru: limit 'referrers' query to scope? #14747

dominikh opened this issue Mar 10, 2016 · 8 comments
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@dominikh
Copy link
Member

Currently, the 'referrers' query checks all packages in GOROOT and GOPATH. Should it optionally be possible to limit it with the -scope flag?

/cc @alandonovan

@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Mar 10, 2016
@alandonovan
Copy link
Contributor

I thought about this and ultimately decided no. The problem is that there are conceptually two different scopes that users care about; call them the "type checking scope" and the "pointer analysis scope".

Most users want the type checking scope, as used by "referrers" and "implements" queries, to be global, since it is relatively quick to find the set of packages that might need to be type checked, and both type checking and result reporting can occur in streaming fashion (although they don't yet). But no user wants the pointer analysis scope to be global because it would make callers/callees/peers queries intolerably slow.

Some users, those with very large workspaces, might want the type checking scope to be less than global, perhaps the same as the pointer analysis scope, or perhaps some independent larger set of packages, but the idea of having not one but two scope parameters in the user interface seemed terribly confusing to me. (One is already too many.) I hope that we can make the referrers and implements queries both fast and streaming, so even users with large workspaces will find them acceptable---even if they sometimes interrupt the tool before it has finishing printing all references to, say, fmt.Println.

@dominikh
Copy link
Member Author

The primary reason I filed this issue wasn't because of performance reasons, but noise. I was interested in referrers, but only in a subset of my workspace. Instead, I got a very long list of uses I wasn't interested in. I'm not sure if this is an issue that should be addressed in guru, or the editor. Doing path-based filtering in the editor might be a close enough approximation to what I want.

@adonovan
Copy link
Member

I agree that whatever we do for implements we should also do for referrers.

@dominikh
Copy link
Member Author

dominikh commented Apr 7, 2016

Another data point: I have a Go corpus of about 250,000 packages that makes up a single GOPATH. I use that corpus for various analyses. Using referrers anywhere in there, however, is pointless right now. Even with streaming output, I'd want to restrict it to specific packages, and I feel that a -scope flag would be a much more straightforward solution than having to construct a temporary GOPATH with symlinks.

@keegancsmith
Copy link
Contributor

keegancsmith commented Jul 26, 2016

-scope packages
comma-separated list of packages the analysis should be limited to

I was surprised that -scope doesn't limit the inspected packages in general. The way I interpret the usage string quoted above is it won't read any other files outside of those packages.

Edit: I see in #14748 you have pretty heavily debated this aspect already. Just take my comment as another data point I suppose.

@athom
Copy link

athom commented Mar 28, 2017

+1, guru referrers is really too slow, making this feature almost useless.
and the -scope make me confusing, seems it can not limit the search scope when guru referrers.
As an end user, I would like to use the_silver_searcher or ack rather than guru referrers, although ag or ack is not accurate enough, at least the speed is acceptable.

@dc0d
Copy link

dc0d commented Nov 18, 2017

Same issue here; guru referrers would be a nice tool for developing other tools. When working in the scope of a certain package, we really are not interested in the whole giant tree under $GOPATH/src (and the one under $GOROOT). This default behavior could be customized using a flag (or the explained one could be activated by a new flag or even by making -scope work as one would expect).

@burke
Copy link

burke commented Jun 12, 2018

Just another data point here: my GOPATH is about 50GB of source (the vast majority of which is not Go) and referrers takes about 30 seconds.

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

9 participants