Commit d5648c7
authored
Validate the CUE Value used in cog go type pipeline (#1297)
## What Changed? Why?
When using the latest version of `cog` (v0.1.4) the `GoTypes` jenny can
take an extremely long time to complete, causing CI to fail. This is
likely due to two issues that are exacerbated by the newer cog versions:
* CUE lazy-evaluates values, and calls to `Subsume()` and `Equals()` do
not cache the evaluations
* `imports.Process` has to load the dependency graph of all imports, and
newer cog versions include a larger graph
This PR aims to solve the first of these two issues, by calling
`Validate()` on the `cue.Value` used in cog go type pipeline before
running it to force CUE to traverse the graph and cache it, reducing
downstream function call times by cog. As a side-effect of this, it also
is now enforcing a valid cue.Value before passing it off to cog (though
at this point in the pipeline is using the parser in `codegen/cuekind`,
it should already be valid).
We can't use `Eval()` instead of `Validate()` (as they both force a
graph traversal and cache), because `Eval()` will resolve reference
values, which can impact output typing from cog.
This PR was spun off of
#1295 to allow it to only
do the dependency upgrades.
### How was it tested?
Locally, using `make regenerate-codegen-test-files`, `make test`, and
`make generate` in `examples/apiserver`, verifying that no changes have
been made to the generated files, and no new errors emerge. The speed-up
with the latest cog has been tested in
#1295
### Where did you document your changes?
Code comments explain the reasoning behind the call to `Validate()`.
### Notes to Reviewers1 parent dd334c5 commit d5648c7
1 file changed
+8
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
202 | | - | |
| 202 | + | |
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
| |||
260 | 260 | | |
261 | 261 | | |
262 | 262 | | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
263 | 270 | | |
264 | 271 | | |
265 | 272 | | |
| |||
0 commit comments