x/tools/go/packages: include directness information to ParseFile callback #28740
Labels
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
Wire recently switched to go/packages after using
golang.org/x/tools/go/loader
. As noted in google/go-cloud#663, we observed a ~4x slowdown. Since not all of the time is spent inside the Wire process, profiling has been difficult. However, for a baseline Wire run that took 2.26s (originally 0.3s), half the time is spent ingo list
, the other half is spent ingo/types.dependencyGraph
and map assignments.This indicates to me that at least part of the problem still is having too much input being sent to the typechecker. One of the tricks Wire employed in the
loader
-based code was to skip function bodies for dependency packages (Wire needs function body type-checking for the root packages). However, theParseFile
callback does not give enough information to make this determination. I would like for the arguments toParseFile
to include whether the file is being parsed for the root packages or imported packages. Something like:It does seem quite possible that more information could be added over time, so a more future-friendly change could be along the lines of:
The text was updated successfully, but these errors were encountered: