cue
cue copied to clipboard
eval: poor performance with large disjunction and matchIf
What version of CUE are you using (cue version)?
$ cue version 2c6ed18e253b33ffe423d6781d1e4b9ac80a5e83
Does this issue reproduce with the latest stable release?
N/A (matchIf isn't present in the latest stable release)
What did you do?
exec time cue vet x.cue
-- x.cue --
import "list"
_schema & _data
_data: {
"updates": [
{
"schedule": {
"interval": "daily"
}
}
],
}
_schema: {
matchIf(
null | bool | number | string | [...] | {"enable-beta-ecosystems"!: true},
_,
null | bool | number | string | [...] | {
"updates"?: null | bool | number | string | [...null | bool | number | string | [...] | {...}] | {...}
...
}
) & {
"updates"!: [...#update]
}
#update: {
"schedule"!: {
"timezone"?: #timezone
...
}
...
}
// This was originally a list of 571 explicit time zones.
#timezone: or([for i in list.Range(0, 571, 1) {"\(i)"}])
}
What did you expect to see?
A run that's reasonably quick.
What did you see instead?
> env CUE_STATS_FILE=stats.cue
> exec time cue vet x.cue
[stderr]
1.38user 0.02system 0:01.08elapsed 130%CPU (0avgtext+0avgdata 68736maxresident)k
0inputs+8outputs (0major+14150minor)pagefaults 0swaps
> exec cat stats.cue
[stdout]
CUE: {
Unifications: 15633
Disjuncts: 46583
Conjuncts: 108394
Freed: 46536
Reused: 45955
Allocs: 608
Retained: 47
}
Go: {
AllocBytes: 248382792
AllocObjects: 9343904
}
PASS
This schema should not be taking over a second to evaluate.