cmd/cue: performance discrepancy between eval / cmd
What version of CUE are you using (cue version)?
$ cue version cue version v0.4.3 linux/amd64
Does this issue reproduce with the latest release?
Yes
What did you do?
Long story short I've got it down to this:
exec cue cmd test ./resources/...
-- cue.mod/module.cue --
module: "cuelang.org/test"
-- test.cue --
package test
import "cuelang.org/test/pkg"
config: pkg.#Config & {"inner": _ | *{"val": ""}}
-- test_tool.cue --
package test
import "cuelang.org/test/pkg"
command: test: pkg.test & {"config": config}
-- pkg/config.cue --
package pkg
#Config: {
inner: _
app: [Name=string]: inner
}
test: config: #Config
-- resources/constraints.cue --
package test
name: string
config: app: (name): {}
-- resources/ns1/app1/test.cue --
package test
name: "app1"
-- resources/ns1/app2/test.cue --
package test
name: "app2"
-- resources/ns1/app3/test.cue --
package test
name: "app3"
-- resources/ns2/app4/test.cue --
package test
name: "app4"
-- resources/ns2/app5/test.cue --
package test
name: "app5"
-- resources/ns2/app6/test.cue --
package test
name: "app6"
-- resources/ns3/app7/test.cue --
package test
name: "app7"
-- resources/ns3/app8/test.cue --
package test
name: "app8"
-- resources/ns3/app9/test.cue --
package test
name: "app9"
-- resources/ns4/app10/test.cue --
package test
name: "app10"
-- resources/ns4/app11/test.cue --
package test
name: "app11"
-- resources/ns4/app12/test.cue --
package test
name: "app12"
What did you expect to see?
That running cue cmd test ./resources/... should take a similar amount of time as cue eval ./resources/... which takes about 0.5 seconds.
What did you see instead?
Running the cue cmd test command takes about 30 seconds, which seems a bit excessive since the command ultimately does nothing.
The origin of this problem comes from a larger configuration where the eval takes about 10 seconds and running a command takes around 500 seconds.
Thanks for the report, @addreas.
I've updated the title to categorise this under cmd/cue - because it's not totally clear from the repro this is a tools/flow issue - there is an awful lot of machinery in cmd/cue cmd which would be "at fault" here.
Sorry, previous comment sent too early.
Also linking to https://github.com/cue-lang/cue/issues/1325 to ensure we get some coverage on problem performance cases in the new implementation.