cuelang.org/go@v0.13.0/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:  27399
    66  Freed:  0
    67  Reused: 0
    68  Allocs: 27399
    69  Retain: 0
    70  
    71  Unifications: 5541
    72  Conjuncts:    25871
    73  Disjuncts:    6534
    74  
    75  CloseIDElems: 85815
    76  NumCloseIDs: 4115
    77  -- out/evalalpha --
    78  (struct){
    79    #Secret: (#struct){
    80      $secret: (#struct){
    81        id: (string){ string }
    82        _id: (string){ string }
    83      }
    84    }
    85    #secrets: (#struct){ |((#struct){
    86        $secret: (#struct){
    87          id: (string){ string }
    88          _id: (string){ string }
    89        }
    90      }, (#struct){
    91      }) }
    92    out: (#struct){
    93      FOO: (#struct){
    94        $secret: (#struct){
    95          id: (string){ "100" }
    96          _id: (string){ "100" }
    97        }
    98      }
    99      ONE: (#struct){
   100        TWO: (#struct){
   101          THREE: (#struct){
   102            $secret: (#struct){
   103              id: (string){ "123" }
   104              _id: (string){ "123" }
   105            }
   106          }
   107        }
   108      }
   109    }
   110    nestedCross: (struct){
   111      closed: (struct){
   112        #D: (#struct){ |((#struct){
   113            id: (string){ string }
   114          }, (#struct){
   115          }) }
   116      }
   117      open: (struct){
   118        D: (struct){ |((struct){
   119            id: (string){ string }
   120          }, (struct){
   121          }) }
   122      }
   123    }
   124    nestedClosed: (struct){
   125      passing: (struct){
   126        D: (struct){ |((struct){
   127            id: (struct){
   128            }
   129          }, (struct){
   130            id: (struct){ |((struct){
   131                id: (struct){
   132                }
   133              }, (struct){
   134              }) }
   135          }, (struct){
   136          }) }
   137      }
   138    }
   139  }
   140  -- diff/-out/evalalpha/stats<==>+out/eval/stats --
   141  diff old new
   142  --- old
   143  +++ new
   144  @@ -1,9 +1,12 @@
   145  -Leaks:  0
   146  -Freed:  1064333
   147  -Reused: 1064282
   148  -Allocs: 51
   149  +Leaks:  27399
   150  +Freed:  0
   151  +Reused: 0
   152  +Allocs: 27399
   153   Retain: 0
   154   
   155  -Unifications: 792123
   156  -Conjuncts:    2480117
   157  -Disjuncts:    1064333
   158  +Unifications: 5541
   159  +Conjuncts:    25871
   160  +Disjuncts:    6534
   161  +
   162  +CloseIDElems: 85815
   163  +NumCloseIDs: 4115
   164  -- diff/-out/evalalpha<==>+out/eval --
   165  diff old new
   166  --- old
   167  +++ new
   168  @@ -56,36 +56,6 @@
   169               }, (struct){
   170               }) }
   171           }, (struct){
   172  -          id: (struct){ |((struct){
   173  -              id: (struct){
   174  -              }
   175  -            }, (struct){
   176  -            }) }
   177  -        }, (struct){
   178  -          id: (struct){ |((struct){
   179  -              id: (struct){
   180  -              }
   181  -            }, (struct){
   182  -            }) }
   183  -        }, (struct){
   184  -          id: (struct){ |((struct){
   185  -              id: (struct){
   186  -              }
   187  -            }, (struct){
   188  -            }) }
   189  -        }, (struct){
   190  -          id: (struct){ |((struct){
   191  -              id: (struct){
   192  -              }
   193  -            }, (struct){
   194  -            }) }
   195  -        }, (struct){
   196  -          id: (struct){ |((struct){
   197  -              id: (struct){
   198  -              }
   199  -            }, (struct){
   200  -            }) }
   201  -        }, (struct){
   202           }) }
   203       }
   204     }
   205  -- diff/explanation --
   206  New algorithm is better at trimming recursive disjunctions.
   207  Note that the old closedness implementation of V3 was able to reduce this to
   208  445 unification ops. This could be due to the fact that the old closedness could
   209  in some cases eliminate earlier than with a flat structure. So this may not be
   210  attainable with the current implementation.
   211  TODO(perf): investigate nonetheless.
   212  -- out/eval/stats --
   213  Leaks:  0
   214  Freed:  1064333
   215  Reused: 1064282
   216  Allocs: 51
   217  Retain: 0
   218  
   219  Unifications: 792123
   220  Conjuncts:    2480117
   221  Disjuncts:    1064333
   222  -- out/eval --
   223  (struct){
   224    #Secret: (#struct){
   225      $secret: (#struct){
   226        id: (string){ string }
   227        _id: (string){ string }
   228      }
   229    }
   230    #secrets: (#struct){ |((#struct){
   231        $secret: (#struct){
   232          id: (string){ string }
   233          _id: (string){ string }
   234        }
   235      }, (#struct){
   236      }) }
   237    out: (#struct){
   238      FOO: (#struct){
   239        $secret: (#struct){
   240          id: (string){ "100" }
   241          _id: (string){ "100" }
   242        }
   243      }
   244      ONE: (#struct){
   245        TWO: (#struct){
   246          THREE: (#struct){
   247            $secret: (#struct){
   248              id: (string){ "123" }
   249              _id: (string){ "123" }
   250            }
   251          }
   252        }
   253      }
   254    }
   255    nestedCross: (struct){
   256      closed: (struct){
   257        #D: (#struct){ |((#struct){
   258            id: (string){ string }
   259          }, (#struct){
   260          }) }
   261      }
   262      open: (struct){
   263        D: (struct){ |((struct){
   264            id: (string){ string }
   265          }, (struct){
   266          }) }
   267      }
   268    }
   269    nestedClosed: (struct){
   270      passing: (struct){
   271        D: (struct){ |((struct){
   272            id: (struct){
   273            }
   274          }, (struct){
   275            id: (struct){ |((struct){
   276                id: (struct){
   277                }
   278              }, (struct){
   279              }) }
   280          }, (struct){
   281            id: (struct){ |((struct){
   282                id: (struct){
   283                }
   284              }, (struct){
   285              }) }
   286          }, (struct){
   287            id: (struct){ |((struct){
   288                id: (struct){
   289                }
   290              }, (struct){
   291              }) }
   292          }, (struct){
   293            id: (struct){ |((struct){
   294                id: (struct){
   295                }
   296              }, (struct){
   297              }) }
   298          }, (struct){
   299            id: (struct){ |((struct){
   300                id: (struct){
   301                }
   302              }, (struct){
   303              }) }
   304          }, (struct){
   305            id: (struct){ |((struct){
   306                id: (struct){
   307                }
   308              }, (struct){
   309              }) }
   310          }, (struct){
   311          }) }
   312      }
   313    }
   314  }
   315  -- out/compile --
   316  --- in.cue
   317  {
   318    #Secret: {
   319      $secret: {
   320        id: string
   321      }
   322    }
   323    #secrets: (〈0;#Secret〉|{
   324      [string]: 〈1;#secrets〉
   325    })
   326    out: (〈0;#secrets〉 & {
   327      FOO: {
   328        $secret: {
   329          id: "100"
   330        }
   331      }
   332      ONE: {
   333        TWO: {
   334          THREE: {
   335            $secret: {
   336              id: "123"
   337            }
   338          }
   339        }
   340      }
   341    })
   342    #Secret: {
   343      $secret: {
   344        _id: string
   345      }
   346    }
   347    #secrets: (〈0;#Secret〉|{
   348      [string]: 〈1;#secrets〉
   349    })
   350    out: (〈0;#secrets〉 & {
   351      FOO: {
   352        $secret: {
   353          _id: "100"
   354        }
   355      }
   356      ONE: {
   357        TWO: {
   358          THREE: {
   359            $secret: {
   360              _id: "123"
   361            }
   362          }
   363        }
   364      }
   365    })
   366  }
   367  --- perf.cue
   368  {
   369    nestedCross: {
   370      closed: {
   371        #D: ({
   372          id: string
   373        }|{
   374          [string]: 〈1;#D〉
   375        })
   376        #D: ({
   377          id: string
   378        }|{
   379          [string]: 〈1;#D〉
   380        })
   381        #D: ({
   382          id: string
   383        }|{
   384          [string]: 〈1;#D〉
   385        })
   386      }
   387    }
   388    nestedCross: {
   389      open: {
   390        D: ({
   391          id: string
   392        }|{
   393          [string]: 〈1;D〉
   394        })
   395        D: ({
   396          id: string
   397        }|{
   398          [string]: 〈1;D〉
   399        })
   400        D: ({
   401          id: string
   402        }|{
   403          [string]: 〈1;D〉
   404        })
   405      }
   406    }
   407    nestedClosed: {
   408      passing: {
   409        D: ({
   410          id: {}
   411        }|{
   412          [string]: 〈1;D〉
   413        })
   414        D: ({
   415          id: {}
   416        }|{
   417          [string]: 〈1;D〉
   418        })
   419        D: ({
   420          id: {}
   421        }|{
   422          [string]: 〈1;D〉
   423        })
   424      }
   425    }
   426  }