-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: cmd/vet: refactor to be cheaper #19732
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
Comments
How expensive is a no-op walk? |
I'm confused. I thought vet already did a single AST walk and called relevant checks for each node: https://github.com/golang/go/blob/master/src/cmd/vet/main.go#L500 Of course, each checker might do non-trivial work once it is running, but I don't think that is a big problem at the moment. |
httpresponse.go rewalks the whole file. I thought there were others, but there aren't. There's something nagging at me here but I clearly haven't expressed it well. |
maybe #8338 is related? |
One experiment that might help (volunteers welcome): implement the -0 check in #19675 and measure how much slower vet gets. If it's significant, can it be improved? |
Did that. CL 38779. No detectable performance change in vet. |
Thanks for the data. We'd forgotten that there's one shared AST walk for most checkers. |
If desired, this could be re-opened and repurposed as an issue to make the httpresponse checker partake of that single shared walk. Although I strongly suspect that that is a low priority on the vet performance front. |
DO NOT REVIEW This is a quick hack for golang#19732. It needs more thought, tests, and docs. Updates golang#19675 Change-Id: Id1a323ba7ec001b2f1a88f30497defc6b823d409
Change https://golang.org/cl/38779 mentions this issue: |
The structure of vet is to have a set of checks, each of which walks the whole AST. This is expensive. It might be possible to refactor it to walk the AST once and do all the work in one pass, or at least to fold many of the locally identifiable issues into a single such pass.
For example, #19675 is not worth a full AST walk but is worth a function call on every constant.
The text was updated successfully, but these errors were encountered: