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
x/tools/go/analysis: specify that all facts are encoded in one gulp, preserving topology #54661
Comments
This proposal has been added to the active column of the proposals project |
Are there even any other drivers? Does anyone object to this proposal? |
I'm aware of at least two: golangci-lint, lintcmd.
Good idea; I had not. golangci-lint decodes a slice of facts all at once but encodes them one at a time, so it would need to be updated. lintcmd decodes facts one at a time, so it too would need to be updated. |
Because:
This seems fine to do even though there are a couple drivers. They can update or not as necessary, but nothing will break. |
Based on the discussion above, this proposal seems like a likely accept. |
No change in consensus, so accepted. 🎉 |
Change https://go.dev/cl/454564 mentions this issue: |
The go/analysis Fact mechanism allows an analysis to associate information with the symbols defined by one package so that it may be retrieved during analysis of another package that imports these symbols. Facts must be pointers to gob-serializable data structures. In many analyses, facts naturally correspond to nodes in some domain-specific graph representation, so that two or more facts conceptually share a large common data structure such as a call graph. It would be a pity if the encoding of such facts caused the representation to explode by a linear factor.
The current specification of the analysis API permits a driver implementation to encode a collection of facts in a single gob operation, so that any shared portions are encoded exactly once and decoding preserves the original topology. The existing drivers in x/tools use the facts helper package and thus already function in this way; this has been verified experimentally.
I propose to change the specification to state that this behavior is required by all drivers. In the meantime, any existing third-party drivers that do not conform may run slower and use more memory for new analysis passes that assume this requirement, but should otherwise compute the correct answer.
The text was updated successfully, but these errors were encountered: