Navigation Menu

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

proposal: cmd/vet: refactor to be cheaper #19732

Closed
robpike opened this issue Mar 27, 2017 · 9 comments
Closed

proposal: cmd/vet: refactor to be cheaper #19732

robpike opened this issue Mar 27, 2017 · 9 comments

Comments

@robpike
Copy link
Contributor

robpike commented Mar 27, 2017

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.

@gopherbot gopherbot added this to the Proposal milestone Mar 27, 2017
@bradfitz
Copy link
Contributor

How expensive is a no-op walk?

@josharian
Copy link
Contributor

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.

@robpike
Copy link
Contributor Author

robpike commented Mar 28, 2017

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.

@haya14busa
Copy link
Contributor

maybe #8338 is related?

@rsc rsc changed the title proposal: refactor vet to be cheaper proposal: cmd/vet: refactor to be cheaper Mar 28, 2017
@rsc
Copy link
Contributor

rsc commented Mar 28, 2017

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?

@josharian
Copy link
Contributor

One experiment that might help (volunteers welcome): implement the -0 check in #19675 and measure how much slower vet gets.

Did that. CL 38779. No detectable performance change in vet.

@rsc
Copy link
Contributor

rsc commented Apr 3, 2017

Thanks for the data. We'd forgotten that there's one shared AST walk for most checkers.

@rsc rsc closed this as completed Apr 3, 2017
@josharian
Copy link
Contributor

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.

josharian added a commit to josharian/go that referenced this issue Apr 11, 2017
DO NOT REVIEW

This is a quick hack for golang#19732.
It needs more thought, tests, and docs.

Updates golang#19675

Change-Id: Id1a323ba7ec001b2f1a88f30497defc6b823d409
@gopherbot
Copy link

Change https://golang.org/cl/38779 mentions this issue: cmd/vet: add check for -0.0

@golang golang locked and limited conversation to collaborators Mar 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants