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

Comments

Projects
None yet
6 participants
@robpike
Copy link
Contributor

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

@gopherbot gopherbot added the Proposal label Mar 27, 2017

@bradfitz

This comment has been minimized.

Copy link
Member

commented Mar 27, 2017

How expensive is a no-op walk?

@josharian

This comment has been minimized.

Copy link
Contributor

commented Mar 27, 2017

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

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Contributor

commented Mar 28, 2017

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

commented Mar 28, 2017

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

This comment has been minimized.

Copy link
Contributor

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 Apr 3, 2017

@josharian

This comment has been minimized.

Copy link
Contributor

commented Apr 3, 2017

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

cmd/vet: add check for -0.0
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

This comment has been minimized.

Copy link

commented Mar 30, 2018

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.
You can’t perform that action at this time.