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
Milestone

Comments

@dominikh
Copy link
Member

@dominikh dominikh commented Mar 10, 2016

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

This comment has been minimized.

Copy link
Contributor

@alandonovan alandonovan commented Mar 16, 2016

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

This comment has been minimized.

Copy link
Member Author

@dominikh dominikh commented Mar 16, 2016

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

This comment has been minimized.

Copy link

@adonovan adonovan commented Mar 25, 2016

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

@dominikh

This comment has been minimized.

Copy link
Member Author

@dominikh 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

This comment has been minimized.

Copy link
Contributor

@keegancsmith 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

This comment has been minimized.

Copy link

@athom 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

This comment has been minimized.

Copy link

@dc0d 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

This comment has been minimized.

Copy link

@burke 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 label Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
9 participants
You can’t perform that action at this time.