cue: evalv3: high memory usage with top-level disjunctions
What version of CUE are you using (cue version)?
$ go run cuelang.org/go/cmd/cue@v0.10.0-alpha.2.0.20240726151100-e68bd632c29e version
cue version v0.10.0-alpha.2.0.20240726151100-e68bd632c29e
go version go1.22.5
-buildmode exe
-compiler gc
CGO_ENABLED 1
GOARCH amd64
GOOS linux
GOAMD64 v1
cue.lang.version v0.10.0
Does this issue reproduce with the latest stable release?
Yes.
What did you do?
After following this to fix another issue, I thought it would be interesting to try the new evaluator again.
https://github.com/cue-lang/cue/issues/3330#issuecomment-2252789316
❯ CUE_EXPERIMENT=evalv3 go run cuelang.org/go/cmd/cue@v0.10.0-alpha.2.0.20240726151100-e68bd632c29e export ./k8s/amour/list.cue
signal: killed
https://github.com/uhthomas/automata/commit/5a1a4fef98e2bf47227079f362e30404eed20674
What did you expect to see?
Successful build.
What did you see instead?
OOM, signal killed.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 20 (20 by maintainers)
Commits related to this issue
- https://github.com/cue-lang/cue/issues/3334 — committed to uhthomas/automata by uhthomas 2 years ago
- internal/core/adt: reuse reqSets slices via OpContext Benchmarking the reduction at https://cuelang.org/issue/3334 via benchcmd -n 12 CueVetIssue3334 cue vet -c f.cue: │ old ... — committed to cue-lang/cue by mvdan 2 years ago
- internal/core/adt: reuse a local buffer in checkTypos The getReplacements call was creating an entirely new slice each time, as can be seen by the inline perf TODO. We can however avoid most of that ... — committed to cue-lang/cue by mvdan 2 years ago
- internal/core/adt: skip work in checkTypos when a vertex has no arcs In looking at why https://github.com/uhthomas/automata was spending so much time in checkTypos, I realised that we were doing a lo... — committed to cue-lang/cue by mvdan 2 years ago
- internal/core/adt: remove unused nodeContext fields nodeContext's overlays and disjunct fields were added and set in https://cuelang.org/cl/1190800 but were never used. Peak memory usage on a simpli... — committed to cue-lang/cue by mvdan 2 years ago
- cue/ast/astutil: refactor walkVisitor away walkVisitor was a wrapper around ast.Walk which kept a stack of visitors to be saved and reused as we walked up and down a syntax tree. Resolve also used a... — committed to cue-lang/cue by mvdan 2 years ago
- internal/core/adt: reuse a slice to make copies of the required reqSets slices.Clone is an efficient way to make a copy of a slice, but it does create a new slice from scratch each time. In this case... — committed to cue-lang/cue by mvdan 2 years ago
- internal/core/adt: avoid apd.Decimal errors in SimplifyBounds apd.Decimal.Int64 on `d = hi - lo` will error if it overflows an int64. This is pretty common with CUE bounds like int64, which expands t... — committed to cue-lang/cue by mvdan 2 years ago
- internal/core/adt: use pointers for snapshot and result in nodeContext These fields are only used in evalv2's disjunction algorithm, so they are entirely unused in evalv3, the current default. Given ... — committed to cue-lang/cue by mvdan a year ago
- internal/core/adt: delay stringifying nodes in errors via fmt.Stringer Particularly given that OpContext.Str ends up calling debug.NodeString, which is relatively expensive to call when creating many... — committed to cue-lang/cue by mvdan a year ago
- internal/core/adt: add benchmark for Issue 3334 This benchmark does not cover all problems related to this issue, but covers the one that are not covered well by current benchmarks and tests. The ma... — committed to cue-lang/cue by mpvl a year ago
- internal/core/adt: remove filter for let sharing This condition seems no longer necessary. Removing gives a significant boost too. Note that with the upcoming memory management, we have no way of fre... — committed to cue-lang/cue by mpvl a year ago
- internal/core/adt: do not set error for nil task state After we add memory management, a node may already have been cleared before a task is completed. This is especially the case in auxiliary tools ... — committed to cue-lang/cue by mpvl a year ago
- internal/core/adt: handle equal disjuncts In some cases a disjunct may be added to itself. It is important in such cases that memory management does not reclaim the "duplicate" node, as it is still a... — committed to cue-lang/cue by mpvl a year ago
- internal/core/adt: delay processing of pattern constraints Processing constraints is not really necessary to compute the final result, as errors are allowed for constraints. It is only necessary for ... — committed to cue-lang/cue by mpvl a year ago
- internal/core/adt: check for nil state in parent disjunction Currently, as nodeContext values are never reclaimed, the value will always be non-nil. In certain cases with API usage, though, a node ma... — committed to cue-lang/cue by mpvl a year ago
- internal/core/adt: basic memory management for evalv3 This implements basic memory management for evalv3. Just as with evalv2, it--for now-- only focuses on reclaiming nodeContext. Unlike evalv2, it ... — committed to cue-lang/cue by mpvl a year ago
- internal/core/adt: trigger more diffs in stats Now we have memory management added, we can trigger more differences based on leaks and allocations. Before, as all allocations were leaks, we did not t... — committed to cue-lang/cue by mpvl a year ago
- internal/core/adt: prune parent processing This has minimal impact on the memory manamagement, but it reintroduces some of the structure sharing diffs that were introduced earlier. Issue #3334 Issue... — committed to cue-lang/cue by mpvl a year ago
- internal/core/adt: mark inlined nodes for cleanup Inlined nodes may not end up as part as the final tree, which means there is no trigger for their cleanup. We register such nodes in the nodeContext... — committed to cue-lang/cue by mpvl a year ago
That said, we still think we can get another 10-30% reduction in allocations relatively easily, so we will definitely attempt that.
I love reading these updates, thanks for your hard work. So exciting to see such significant progress! I’m also grateful my repository has been helpful for evaluating performance.
Significant progress; I am now able to finish evaluating with evalv3, even if it’s still quite a bit slower than evalv2:
With @mpvl we believe the remaining work here is memory management, which evalv2 did to some extent, but evalv3 does not do yet. This is also why evalv3 above takes more than 20GiB of memory to finish.