cuelang.org/go@v0.10.1/cue/testdata/benchmarks/issue1684.txtar (about) 1 #Issue: 1684 2 3 // TODO: significantly reduce the number of counts in this evaluation. 4 -- stats.txt -- 5 Leaks: 0 6 Freed: 995025 7 Reused: 994976 8 Allocs: 49 9 Retain: 0 10 11 Unifications: 740771 12 Conjuncts: 3143640 13 Disjuncts: 995025 14 15 -- in.cue -- 16 #Secret: { 17 $secret: id: string 18 } 19 #secrets: #Secret | {[string]: #secrets} 20 21 out: #secrets & { 22 FOO: $secret: id: "100" 23 ONE: TWO: THREE: $secret: id: "123" 24 } 25 26 #Secret: { 27 $secret: _id: string 28 } 29 #secrets: #Secret | {[string]: #secrets} 30 31 out: #secrets & { 32 FOO: $secret: _id: "100" 33 ONE: TWO: THREE: $secret: _id: "123" 34 } 35 36 -- perf.cue -- 37 nestedCross: closed: { 38 #D: {id: string} | {[string]: #D} 39 #D: {id: string} | {[string]: #D} 40 #D: {id: string} | {[string]: #D} 41 } 42 43 nestedCross: open: { 44 D: {id: string} | {[string]: D} 45 D: {id: string} | {[string]: D} 46 D: {id: string} | {[string]: D} 47 } 48 49 // TODO(perf): support this case. This is currently highly exponential. 50 // The old evaluator solved this performance issue by simply ignoring equality 51 // for patterns. This led to duplicate disjunctions and incorrect results. 52 // 53 // The new evaluator computes the correct result, but is highly exponential. 54 // The solution is probably to limit structural cycle depth. 55 // 56 // An alternative would be to stop processing disjunctions if we see there are 57 // more than two solutions. This might still result in exponential behavior, 58 // but will limit it considerably. 59 nestedClosed: passing: { 60 D: {id: {}} | {[string]: D} 61 D: {id: {}} | {[string]: D} 62 D: {id: {}} | {[string]: D} 63 } 64 -- out/evalalpha/stats -- 65 Leaks: 2533 66 Freed: 612 67 Reused: 612 68 Allocs: 2533 69 Retain: 0 70 71 Unifications: 707 72 Conjuncts: 5373 73 Disjuncts: 1102 74 -- out/evalalpha -- 75 (struct){ 76 #Secret: (#struct){ 77 $secret: (#struct){ 78 id: (string){ string } 79 _id: (string){ string } 80 } 81 } 82 #secrets: (#struct){ |((#struct){ 83 $secret: (#struct){ 84 id: (string){ string } 85 _id: (string){ string } 86 } 87 }, (#struct){ 88 }) } 89 out: (#struct){ 90 FOO: (#struct){ 91 $secret: (#struct){ 92 id: (string){ "100" } 93 _id: (string){ "100" } 94 } 95 } 96 ONE: (#struct){ 97 TWO: (#struct){ 98 THREE: (#struct){ 99 $secret: (#struct){ 100 id: (string){ "123" } 101 _id: (string){ "123" } 102 } 103 } 104 } 105 } 106 } 107 nestedCross: (struct){ 108 closed: (struct){ 109 #D: (#struct){ |((#struct){ 110 id: (string){ string } 111 }, (#struct){ 112 }) } 113 } 114 open: (struct){ 115 D: (struct){ |((struct){ 116 id: (string){ string } 117 }, (struct){ 118 }) } 119 } 120 } 121 nestedClosed: (struct){ 122 passing: (struct){ 123 D: (struct){ |((struct){ 124 id: (struct){ 125 } 126 }, (struct){ 127 id: (struct){ |((struct){ 128 id: (struct){ 129 } 130 }, (struct){ 131 id: (struct){ |((struct){ 132 id: (struct){ 133 } 134 }, (struct){ 135 }) } 136 }, (struct){ 137 }) } 138 }, (struct){ 139 }) } 140 } 141 } 142 } 143 -- diff/-out/evalalpha/stats<==>+out/eval/stats -- 144 diff old new 145 --- old 146 +++ new 147 @@ -1,9 +1,9 @@ 148 -Leaks: 0 149 -Freed: 1064333 150 -Reused: 1064282 151 -Allocs: 51 152 +Leaks: 2533 153 +Freed: 612 154 +Reused: 612 155 +Allocs: 2533 156 Retain: 0 157 158 -Unifications: 792123 159 -Conjuncts: 2480117 160 -Disjuncts: 1064333 161 +Unifications: 707 162 +Conjuncts: 5373 163 +Disjuncts: 1102 164 -- diff/-out/evalalpha<==>+out/eval -- 165 diff old new 166 --- old 167 +++ new 168 @@ -54,35 +54,11 @@ 169 id: (struct){ 170 } 171 }, (struct){ 172 - }) } 173 - }, (struct){ 174 - id: (struct){ |((struct){ 175 - id: (struct){ 176 - } 177 - }, (struct){ 178 - }) } 179 - }, (struct){ 180 - id: (struct){ |((struct){ 181 - id: (struct){ 182 - } 183 - }, (struct){ 184 - }) } 185 - }, (struct){ 186 - id: (struct){ |((struct){ 187 - id: (struct){ 188 - } 189 - }, (struct){ 190 - }) } 191 - }, (struct){ 192 - id: (struct){ |((struct){ 193 - id: (struct){ 194 - } 195 - }, (struct){ 196 - }) } 197 - }, (struct){ 198 - id: (struct){ |((struct){ 199 - id: (struct){ 200 - } 201 + id: (struct){ |((struct){ 202 + id: (struct){ 203 + } 204 + }, (struct){ 205 + }) } 206 }, (struct){ 207 }) } 208 }, (struct){ 209 -- out/eval/stats -- 210 Leaks: 0 211 Freed: 1064333 212 Reused: 1064282 213 Allocs: 51 214 Retain: 0 215 216 Unifications: 792123 217 Conjuncts: 2480117 218 Disjuncts: 1064333 219 -- out/eval -- 220 (struct){ 221 #Secret: (#struct){ 222 $secret: (#struct){ 223 id: (string){ string } 224 _id: (string){ string } 225 } 226 } 227 #secrets: (#struct){ |((#struct){ 228 $secret: (#struct){ 229 id: (string){ string } 230 _id: (string){ string } 231 } 232 }, (#struct){ 233 }) } 234 out: (#struct){ 235 FOO: (#struct){ 236 $secret: (#struct){ 237 id: (string){ "100" } 238 _id: (string){ "100" } 239 } 240 } 241 ONE: (#struct){ 242 TWO: (#struct){ 243 THREE: (#struct){ 244 $secret: (#struct){ 245 id: (string){ "123" } 246 _id: (string){ "123" } 247 } 248 } 249 } 250 } 251 } 252 nestedCross: (struct){ 253 closed: (struct){ 254 #D: (#struct){ |((#struct){ 255 id: (string){ string } 256 }, (#struct){ 257 }) } 258 } 259 open: (struct){ 260 D: (struct){ |((struct){ 261 id: (string){ string } 262 }, (struct){ 263 }) } 264 } 265 } 266 nestedClosed: (struct){ 267 passing: (struct){ 268 D: (struct){ |((struct){ 269 id: (struct){ 270 } 271 }, (struct){ 272 id: (struct){ |((struct){ 273 id: (struct){ 274 } 275 }, (struct){ 276 }) } 277 }, (struct){ 278 id: (struct){ |((struct){ 279 id: (struct){ 280 } 281 }, (struct){ 282 }) } 283 }, (struct){ 284 id: (struct){ |((struct){ 285 id: (struct){ 286 } 287 }, (struct){ 288 }) } 289 }, (struct){ 290 id: (struct){ |((struct){ 291 id: (struct){ 292 } 293 }, (struct){ 294 }) } 295 }, (struct){ 296 id: (struct){ |((struct){ 297 id: (struct){ 298 } 299 }, (struct){ 300 }) } 301 }, (struct){ 302 id: (struct){ |((struct){ 303 id: (struct){ 304 } 305 }, (struct){ 306 }) } 307 }, (struct){ 308 }) } 309 } 310 } 311 } 312 -- out/compile -- 313 --- in.cue 314 { 315 #Secret: { 316 $secret: { 317 id: string 318 } 319 } 320 #secrets: (〈0;#Secret〉|{ 321 [string]: 〈1;#secrets〉 322 }) 323 out: (〈0;#secrets〉 & { 324 FOO: { 325 $secret: { 326 id: "100" 327 } 328 } 329 ONE: { 330 TWO: { 331 THREE: { 332 $secret: { 333 id: "123" 334 } 335 } 336 } 337 } 338 }) 339 #Secret: { 340 $secret: { 341 _id: string 342 } 343 } 344 #secrets: (〈0;#Secret〉|{ 345 [string]: 〈1;#secrets〉 346 }) 347 out: (〈0;#secrets〉 & { 348 FOO: { 349 $secret: { 350 _id: "100" 351 } 352 } 353 ONE: { 354 TWO: { 355 THREE: { 356 $secret: { 357 _id: "123" 358 } 359 } 360 } 361 } 362 }) 363 } 364 --- perf.cue 365 { 366 nestedCross: { 367 closed: { 368 #D: ({ 369 id: string 370 }|{ 371 [string]: 〈1;#D〉 372 }) 373 #D: ({ 374 id: string 375 }|{ 376 [string]: 〈1;#D〉 377 }) 378 #D: ({ 379 id: string 380 }|{ 381 [string]: 〈1;#D〉 382 }) 383 } 384 } 385 nestedCross: { 386 open: { 387 D: ({ 388 id: string 389 }|{ 390 [string]: 〈1;D〉 391 }) 392 D: ({ 393 id: string 394 }|{ 395 [string]: 〈1;D〉 396 }) 397 D: ({ 398 id: string 399 }|{ 400 [string]: 〈1;D〉 401 }) 402 } 403 } 404 nestedClosed: { 405 passing: { 406 D: ({ 407 id: {} 408 }|{ 409 [string]: 〈1;D〉 410 }) 411 D: ({ 412 id: {} 413 }|{ 414 [string]: 〈1;D〉 415 }) 416 D: ({ 417 id: {} 418 }|{ 419 [string]: 〈1;D〉 420 }) 421 } 422 } 423 }