x/tools/go/analysis/passes: opt: skip each ast.File that doesn't import the package of interest #60749
Labels
Analysis
Issues related to static analysis (vet, x/tools/go/analysis)
gopls/analysis
Issues related to running analysis in gopls
gopls/performance
Issues related to gopls performance (CPU, memory, etc).
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
Many go/analysis checkers start by inspecting the import map of the package, and making an early return if a specific package of interest is not found, for example:
This check is a substantial optimization. Indeed, in recent experiments we discovered that all the traversals done by static checkers can be quite significant relative to type checking---so much so that gopls' separation of analyzer sets into "all" (for root packages) and "fact-only" (for dependencies) is well worth doing.
We could take it a step further by skipping individual files if they don't import the package of interest. That's easy when the traversal uses ast.Inspect, but harder if it uses the Inspector, since the latter searches all files of the package.
The task of this issue is to try to find a convenient way to skip traversal of files that lack the necessary import, and measure the benefit.
The text was updated successfully, but these errors were encountered: