Skip to content

Commit 1b7a71c

Browse files
committed
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 #2850 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Iac68285c07525959cb607f3df34b726169a55f7f Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1218188 Unity-Result: CUE porcuepine <[email protected]> Reviewed-by: Daniel Martí <[email protected]> TryBot-Result: CUEcueckoo <[email protected]>
1 parent f389502 commit 1b7a71c

File tree

4 files changed

+47
-40
lines changed

4 files changed

+47
-40
lines changed

cue/testdata/benchmarks/issue3514.txtar

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ _schema: {
3636
#timezone: or([for i in list.Range(0, 571, 1) {"\(i)"}])
3737
}
3838
-- out/evalalpha/stats --
39-
Leaks: 1165
39+
Leaks: 1164
4040
Freed: 2438
41-
Reused: 1865
41+
Reused: 1864
4242
Allocs: 1738
4343
Retain: 0
4444

45-
Unifications: 51
46-
Conjuncts: 7011
45+
Unifications: 50
46+
Conjuncts: 7010
4747
Disjuncts: 2362
4848

4949
CloseIDElems: 35
@@ -62,14 +62,14 @@ diff old new
6262
-Unifications: 189
6363
-Conjuncts: 92950
6464
-Disjuncts: 31139
65-
+Leaks: 1165
65+
+Leaks: 1164
6666
+Freed: 2438
67-
+Reused: 1865
67+
+Reused: 1864
6868
+Allocs: 1738
6969
+Retain: 0
7070
+
71-
+Unifications: 51
72-
+Conjuncts: 7011
71+
+Unifications: 50
72+
+Conjuncts: 7010
7373
+Disjuncts: 2362
7474
+
7575
+CloseIDElems: 35

cue/testdata/cycle/constraints.txtar

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -955,9 +955,7 @@ Result:
955955
p1: (_|_){
956956
// [structural cycle]
957957
D: (struct){
958-
a?: (_|_){
959-
// [structural cycle]
960-
}
958+
a?: ~(brokenRing.t1.p1.T)
961959
}
962960
T: (_|_){
963961
// [structural cycle]
@@ -1162,17 +1160,21 @@ diff old new
11621160
}
11631161
}
11641162
}
1165-
@@ -379,9 +368,6 @@
1163+
@@ -377,12 +366,7 @@
1164+
p1: (_|_){
1165+
// [structural cycle]
11661166
D: (struct){
1167-
a?: (_|_){
1168-
// [structural cycle]
1167+
- a?: (_|_){
1168+
- // [structural cycle]
11691169
- b: (_|_){
11701170
- // [structural cycle] brokenRing.t1.p1.D.a.b: structural cycle
11711171
- }
1172-
}
1172+
- }
1173+
+ a?: ~(brokenRing.t1.p1.T)
11731174
}
11741175
T: (_|_){
1175-
@@ -393,11 +379,7 @@
1176+
// [structural cycle]
1177+
@@ -393,11 +377,7 @@
11761178
}
11771179
p2: (struct){
11781180
T: (struct){
@@ -1185,7 +1187,7 @@ diff old new
11851187
}
11861188
D: (struct){
11871189
a?: (_|_){
1188-
@@ -431,12 +413,7 @@
1190+
@@ -431,12 +411,7 @@
11891191
// [structural cycle]
11901192
D: (_|_){
11911193
// [structural cycle]

cue/testdata/cycle/structural.txtar

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,9 +1412,7 @@ Result:
14121412
issue2545: (_|_){
14131413
// [structural cycle]
14141414
#A: (#struct){
1415-
B?: (_|_){
1416-
// [structural cycle]
1417-
}
1415+
B?: ~(issue2545.#B)
14181416
}
14191417
#B: (_|_){
14201418
// [structural cycle]
@@ -2258,17 +2256,21 @@ diff old new
22582256
}
22592257
}
22602258
}
2261-
@@ -815,9 +780,6 @@
2259+
@@ -813,12 +778,7 @@
2260+
issue2545: (_|_){
2261+
// [structural cycle]
22622262
#A: (#struct){
2263-
B?: (_|_){
2264-
// [structural cycle]
2263+
- B?: (_|_){
2264+
- // [structural cycle]
22652265
- A: (_|_){
22662266
- // [structural cycle] issue2545.#A.B.A: structural cycle
22672267
- }
2268-
}
2268+
- }
2269+
+ B?: ~(issue2545.#B)
22692270
}
22702271
#B: (_|_){
2271-
@@ -863,11 +825,9 @@
2272+
// [structural cycle]
2273+
@@ -863,11 +823,9 @@
22722274
// [eval] e3.a: conflicting values [a] and {c:a} (mismatched types list and struct):
22732275
// ./in.cue:412:5
22742276
// ./in.cue:413:5
@@ -2283,7 +2285,7 @@ diff old new
22832285
}
22842286
}
22852287
b: (_|_){
2286-
@@ -874,11 +834,9 @@
2288+
@@ -874,11 +832,9 @@
22872289
// [eval] e3.b: conflicting values [b] and {c:b} (mismatched types list and struct):
22882290
// ./in.cue:415:5
22892291
// ./in.cue:416:5
@@ -2298,7 +2300,7 @@ diff old new
22982300
}
22992301
}
23002302
}
2301-
@@ -892,11 +850,10 @@
2303+
@@ -892,11 +848,10 @@
23022304
// ./in.cue:420:10
23032305
// ./in.cue:421:6
23042306
// e4.a.0.0: 2 errors in empty disjunction:
@@ -2312,7 +2314,7 @@ diff old new
23122314
// ./in.cue:420:10
23132315
// ./in.cue:421:6
23142316
0: (struct){
2315-
@@ -912,12 +869,11 @@
2317+
@@ -912,12 +867,11 @@
23162318
// ./in.cue:423:6
23172319
// ./in.cue:424:10
23182320
// e4.b.0.0: 2 errors in empty disjunction:
@@ -2327,7 +2329,7 @@ diff old new
23272329
// ./in.cue:424:10
23282330
0: (struct){
23292331
c: (int){ 1 }
2330-
@@ -945,17 +901,16 @@
2332+
@@ -945,17 +899,16 @@
23312333
// [eval]
23322334
0: (_|_){
23332335
// [eval] nestedList.v1e.y.0: 4 errors in empty disjunction:
@@ -2350,7 +2352,7 @@ diff old new
23502352
1: (int){ 1 }
23512353
}
23522354
1: (int){ 1 }
2353-
@@ -967,17 +922,16 @@
2355+
@@ -967,17 +920,16 @@
23542356
// [eval]
23552357
0: (_|_){
23562358
// [eval] nestedList.v2e.y.0: 4 errors in empty disjunction:
@@ -2373,7 +2375,7 @@ diff old new
23732375
1: (int){ 1 }
23742376
}
23752377
1: (int){ 1 }
2376-
@@ -1031,7 +985,10 @@
2378+
@@ -1031,7 +983,10 @@
23772379
head: (int){ 3 }
23782380
tail: (struct){
23792381
head: (int){ 4 }
@@ -2385,7 +2387,7 @@ diff old new
23852387
}
23862388
}
23872389
}
2388-
@@ -1045,7 +1002,10 @@
2390+
@@ -1045,7 +1000,10 @@
23892391
head: (int){ 2 }
23902392
tail: (struct){
23912393
head: (int){ 3 }
@@ -2397,7 +2399,7 @@ diff old new
23972399
}
23982400
}
23992401
}
2400-
@@ -1059,8 +1019,12 @@
2402+
@@ -1059,8 +1017,12 @@
24012403
head: (int){ 2 }
24022404
tail: (struct){ |((struct){
24032405
head: (int){ 3 }
@@ -2412,7 +2414,7 @@ diff old new
24122414
}, (struct){
24132415
head: (int){ 3 }
24142416
}) }
2415-
@@ -1082,9 +1046,7 @@
2417+
@@ -1082,9 +1044,7 @@
24162418
// [structural cycle]
24172419
f: (_|_){
24182420
// [structural cycle]
@@ -2423,7 +2425,7 @@ diff old new
24232425
}
24242426
g: (_|_){
24252427
// [structural cycle]
2426-
@@ -1105,10 +1067,7 @@
2428+
@@ -1105,10 +1065,7 @@
24272429
x: (_){ _ }
24282430
y: (_){ _ }
24292431
}
@@ -2435,7 +2437,7 @@ diff old new
24352437
}
24362438
}
24372439
t2: (struct){
2438-
@@ -1121,10 +1080,7 @@
2440+
@@ -1121,10 +1078,7 @@
24392441
x: (_){ _ }
24402442
y: (_){ _ }
24412443
}
@@ -2447,7 +2449,7 @@ diff old new
24472449
}
24482450
}
24492451
t3: (struct){
2450-
@@ -1139,16 +1095,8 @@
2452+
@@ -1139,16 +1093,8 @@
24512453
y: (_){ _ }
24522454
z: (_){ _ }
24532455
}
@@ -2466,7 +2468,7 @@ diff old new
24662468
}
24672469
}
24682470
t4: (struct){
2469-
@@ -1164,51 +1112,11 @@
2471+
@@ -1164,51 +1110,11 @@
24702472
y: (_){ _ }
24712473
z: (_){ _ }
24722474
}
@@ -2523,7 +2525,7 @@ diff old new
25232525
}
25242526
}
25252527
t5: (struct){
2526-
@@ -1219,18 +1127,8 @@
2528+
@@ -1219,18 +1125,8 @@
25272529
}
25282530
}
25292531
C: (struct){
@@ -2544,7 +2546,7 @@ diff old new
25442546
}
25452547
}
25462548
}
2547-
@@ -1253,19 +1151,19 @@
2549+
@@ -1253,19 +1149,19 @@
25482550
}
25492551
}
25502552
n4: (struct){

internal/core/adt/composite.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,9 @@ func (v *Vertex) IsDefined(c *OpContext) bool {
368368
if v.isDefined() {
369369
return true
370370
}
371+
if v.Parent != nil && v.Parent.status == finalized {
372+
return false
373+
}
371374
v.Finalize(c)
372375
return v.isDefined()
373376
}

0 commit comments

Comments
 (0)