From 51bf6f2cd92d4a1694c47a1a76c78a23a2689e9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Mon, 29 Jul 2024 17:23:12 +0100 Subject: [PATCH] tools/flow: add test case for issue 2559 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The added CUE takes 7s to test with tools/flow or run with `cue cmd`, as it's adapted from https://github.com/MarcWort/example-cue to show the worst case scenario of tools/flow being slow by nesting many references to non-task nodes which do some underlying work. Thanks to Marc W for providing the original reproducer on GitHub. For #2559. Signed-off-by: Daniel Martí Change-Id: I25543e7c22b1dda6a8a8528198d2d7b4a63bb411 Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1198565 Unity-Result: CUE porcuepine TryBot-Result: CUEcueckoo Reviewed-by: Roger Peppe --- tools/flow/testdata/issue2559.txtar | 104 ++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 tools/flow/testdata/issue2559.txtar diff --git a/tools/flow/testdata/issue2559.txtar b/tools/flow/testdata/issue2559.txtar new file mode 100644 index 00000000000..b2e1ff1212d --- /dev/null +++ b/tools/flow/testdata/issue2559.txtar @@ -0,0 +1,104 @@ +#IgnoreConcrete: true +#InferTasks: true +-- in.cue -- +package p + +import ( + "list" + "tool/cli" +) + +root: test: cli.Print & { text: "\(len(list.FlattenN(indir1, 10)))" } + +indir1: [if len(indir2) > 0 { indir2 }] +indir2: [if len(indir3) > 0 { indir3 }] +indir3: [if len(indir4) > 0 { indir4 }] +indir4: indir5 +indir5: indir6 +indir6: indir7 +indir7: [for i in list.Range(1,20,4) { + #pair & { + one: n: 0 + two: n: i + } +}] + +#pair: { + one: #unit & { + n: <25 + } + two: #unit & { + n: >=one.n + if n == one.n { + n: <= one.n + } + } + if two.n > one.n { + one: n: 0 + } +} + +#unit: { + n: int + #padding: {in: <10, out: "0\(in)"} | {in: >=10, out: "\(in)"} + str: (#padding & {in: n}).out +} +-- out/run/errors -- +-- out/run/t0 -- +graph TD + t0("root.test [Ready]") + +-- out/run/t1 -- +graph TD + t0("root.test [Terminated]") + +-- out/run/t1/value -- +{ + $id: "tool/cli.Print" + stdout: "foo" + text: "5" +} +-- out/run/t1/stats -- +Leaks: 0 +Freed: 262168 +Reused: 262148 +Allocs: 20 +Retain: 352 + +Unifications: 187362 +Conjuncts: 902602 +Disjuncts: 262432 +-- out/run/stats/totals -- +Leaks: 0 +Freed: 262168 +Reused: 262148 +Allocs: 20 +Retain: 352 + +Unifications: 187362 +Conjuncts: 902602 +Disjuncts: 262432 +-- out/run/t2 -- +graph TD + t0("root.prepare [Terminated]") + t1("root.run [Terminated]") + t1-->t0 + +-- out/run/t2/value -- +{ + $id: "run" + stdout: "foo" + env: { + input: "foo" + } +} +-- out/run/t2/stats -- +Leaks: 0 +Freed: 12 +Reused: 12 +Allocs: 0 +Retain: 0 + +Unifications: 12 +Conjuncts: 20 +Disjuncts: 12