Skip to content

Commit

Permalink
internal/core/adt: distinguish point of cyclicity
Browse files Browse the repository at this point in the history
We will treat the point where cyclicity of a conjunct
is considered slightly differently for ancestor cycles
and indirect cycles through reoccuring references.

This fixes some spurious cycles and is needed for
upcoming changes.

See updated comments for more detail.

Issue #2850
Issue #2854

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I6547ff13436999fcee316971afb0830051086cfe
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1202213
Unity-Result: CUE porcuepine <[email protected]>
Reviewed-by: Matthew Sackman <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
  • Loading branch information
mpvl committed Oct 8, 2024
1 parent 2d4a895 commit af68c6c
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 115 deletions.
16 changes: 8 additions & 8 deletions cue/testdata/benchmarks/issue1684.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ nestedClosed: passing: {
}
-- out/evalalpha/stats --
Leaks: 2135
Freed: 658
Reused: 658
Freed: 530
Reused: 530
Allocs: 2135
Retain: 0

Unifications: 475
Conjuncts: 4781
Disjuncts: 918
Conjuncts: 4333
Disjuncts: 790
-- out/evalalpha --
(struct){
#Secret: (#struct){
Expand Down Expand Up @@ -144,17 +144,17 @@ diff old new
-Reused: 1064282
-Allocs: 51
+Leaks: 2135
+Freed: 658
+Reused: 658
+Freed: 530
+Reused: 530
+Allocs: 2135
Retain: 0

-Unifications: 792123
-Conjuncts: 2480117
-Disjuncts: 1064333
+Unifications: 475
+Conjuncts: 4781
+Disjuncts: 918
+Conjuncts: 4333
+Disjuncts: 790
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
Expand Down
20 changes: 10 additions & 10 deletions cue/testdata/cycle/comprehension.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -310,15 +310,15 @@ issue2367: {
}

-- out/evalalpha/stats --
Leaks: 790
Leaks: 786
Freed: 56
Reused: 56
Allocs: 790
Allocs: 786
Retain: 0

Unifications: 494
Conjuncts: 2966
Disjuncts: 198
Unifications: 487
Conjuncts: 2953
Disjuncts: 196
-- out/evalalpha --
Errors:
selfReferential.insertionError.A: adding field foo3 not allowed as field set was already referenced:
Expand Down Expand Up @@ -1184,18 +1184,18 @@ diff old new
-Reused: 1260
-Allocs: 60
-Retain: 145
+Leaks: 790
+Leaks: 786
+Freed: 56
+Reused: 56
+Allocs: 790
+Allocs: 786
+Retain: 0

-Unifications: 832
-Conjuncts: 2525
-Disjuncts: 1404
+Unifications: 494
+Conjuncts: 2966
+Disjuncts: 198
+Unifications: 487
+Conjuncts: 2953
+Disjuncts: 196
-- out/eval/stats --
Leaks: 50
Freed: 1270
Expand Down
50 changes: 13 additions & 37 deletions cue/testdata/cycle/constraints.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@ Conjuncts: 321
Disjuncts: 147
-- out/evalalpha --
Errors:
mutuallyTriggeringCycle.t1.x.c.b.b.b.b.b.b: structural cycle
noCancelSelfInvoke.t1.x.c.b.b.b.b.b: structural cycle
mutuallyTriggeringCycle.t1.x.c.b.b.b.b.b: structural cycle
noCancelSelfInvoke.t1.x.c.b.b: structural cycle
noCancelSelfInvoke.t1.x.c.c: structural cycle
selfTriggerCycle.issue1503.#T.a.b.link: structural cycle
selfTriggerCycle.long1.a.c.b.c.b.c.b: structural cycle
Expand Down Expand Up @@ -639,16 +639,7 @@ Result:
b: (_|_){
// [structural cycle]
b: (_|_){
// [structural cycle]
b: (_|_){
// [structural cycle]
b: (_|_){
// [structural cycle]
b: (_|_){
// [structural cycle] noCancelSelfInvoke.t1.x.c.b.b.b.b.b: structural cycle
}
}
}
// [structural cycle] noCancelSelfInvoke.t1.x.c.b.b: structural cycle
}
}
c: (_|_){
Expand Down Expand Up @@ -777,10 +768,7 @@ Result:
b: (_|_){
// [structural cycle]
b: (_|_){
// [structural cycle]
b: (_|_){
// [structural cycle] mutuallyTriggeringCycle.t1.x.c.b.b.b.b.b.b: structural cycle
}
// [structural cycle] mutuallyTriggeringCycle.t1.x.c.b.b.b.b.b: structural cycle
}
}
}
Expand All @@ -799,8 +787,8 @@ diff old new
Errors:
-mutuallyTriggeringCycle.t1.x.c.b.b.b.b: structural cycle
-noCancelSelfInvoke.t1.x.c.b.b.b: structural cycle
+mutuallyTriggeringCycle.t1.x.c.b.b.b.b.b.b: structural cycle
+noCancelSelfInvoke.t1.x.c.b.b.b.b.b: structural cycle
+mutuallyTriggeringCycle.t1.x.c.b.b.b.b.b: structural cycle
+noCancelSelfInvoke.t1.x.c.b.b: structural cycle
noCancelSelfInvoke.t1.x.c.c: structural cycle
selfTriggerCycle.issue1503.#T.a.b.link: structural cycle
-selfTriggerCycle.long1.a.c.b.c.b.c.b.c.b: structural cycle
Expand Down Expand Up @@ -831,23 +819,14 @@ diff old new
}
#S: (#struct){
y: (#struct){
@@ -198,18 +190,24 @@
@@ -198,18 +190,15 @@
// [structural cycle]
c: (_|_){
// [structural cycle]
+ b: (_|_){
+ // [structural cycle]
+ b: (_|_){
+ // [structural cycle]
+ b: (_|_){
+ // [structural cycle]
+ b: (_|_){
+ // [structural cycle]
+ b: (_|_){
+ // [structural cycle] noCancelSelfInvoke.t1.x.c.b.b.b.b.b: structural cycle
+ }
+ }
+ }
+ // [structural cycle] noCancelSelfInvoke.t1.x.c.b.b: structural cycle
+ }
+ }
c: (_|_){
Expand All @@ -865,7 +844,7 @@ diff old new
}
}
}
@@ -218,12 +216,7 @@
@@ -218,12 +207,7 @@
// [structural cycle]
t1: (_|_){
// [structural cycle]
Expand All @@ -879,7 +858,7 @@ diff old new
#T: (_|_){
// [structural cycle]
b: (_|_){
@@ -263,13 +256,7 @@
@@ -263,13 +247,7 @@
c: (_|_){
// [structural cycle]
b: (_|_){
Expand All @@ -894,7 +873,7 @@ diff old new
}
}
}
@@ -284,20 +271,29 @@
@@ -284,20 +262,29 @@
// [structural cycle]
a: (_|_){
// [structural cycle]
Expand Down Expand Up @@ -934,17 +913,14 @@ diff old new
}
}
}
@@ -333,7 +329,13 @@
@@ -333,7 +320,10 @@
b: (_|_){
// [structural cycle]
b: (_|_){
- // [structural cycle] mutuallyTriggeringCycle.t1.x.c.b.b.b.b: structural cycle
+ // [structural cycle]
+ b: (_|_){
+ // [structural cycle]
+ b: (_|_){
+ // [structural cycle] mutuallyTriggeringCycle.t1.x.c.b.b.b.b.b.b: structural cycle
+ }
+ // [structural cycle] mutuallyTriggeringCycle.t1.x.c.b.b.b.b.b: structural cycle
+ }
}
}
Expand Down
36 changes: 18 additions & 18 deletions cue/testdata/cycle/issue990.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@ This seems to be the result of incorrect handling of disjunctions.
-- diff/todo/p3 --
Reordering
-- out/evalalpha/stats --
Leaks: 2075
Freed: 218
Reused: 218
Allocs: 2075
Leaks: 1369
Freed: 139
Reused: 139
Allocs: 1369
Retain: 0

Unifications: 205
Conjuncts: 6343
Disjuncts: 436
Unifications: 173
Conjuncts: 4434
Disjuncts: 278
-- out/evalalpha --
Errors:
out.subs.subs: structural cycle:
out.subs: structural cycle:
./in.cue:34:17

Result:
Expand Down Expand Up @@ -241,7 +241,7 @@ Result:
}
}
out: (_|_){
// [structural cycle] out.subs.subs: structural cycle:
// [structural cycle] out.subs: structural cycle:
// ./in.cue:34:17
}
}
Expand All @@ -255,26 +255,26 @@ diff old new
-Reused: 3200
-Allocs: 25
-Retain: 26
+Leaks: 2075
+Freed: 218
+Reused: 218
+Allocs: 2075
+Leaks: 1369
+Freed: 139
+Reused: 139
+Allocs: 1369
+Retain: 0

-Unifications: 2577
-Conjuncts: 12017
-Disjuncts: 3244
+Unifications: 205
+Conjuncts: 6343
+Disjuncts: 436
+Unifications: 173
+Conjuncts: 4434
+Disjuncts: 278
-- diff/-out/evalalpha<==>+out/eval --
diff old new
--- old
+++ new
@@ -1,32 +1,23 @@
-(struct){
+Errors:
+out.subs.subs: structural cycle:
+out.subs: structural cycle:
+ ./in.cue:34:17
+
+Result:
Expand Down Expand Up @@ -612,7 +612,7 @@ diff old new
+ }
+ }
+ out: (_|_){
+ // [structural cycle] out.subs.subs: structural cycle:
+ // [structural cycle] out.subs: structural cycle:
+ // ./in.cue:34:17
}
}
Expand Down
Loading

0 comments on commit af68c6c

Please sign in to comment.