-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/core/adt: introduce structure sharing
Structure sharing allows the same node to be used in multiple positions if the evaluation is known to be the same. This is particularly the case if a field has a single reference to another field: a: b // reference to b can be used as is b: 2 Structure sharing has the potential to greatly reduce the time complexity of evaluation in certain conditions. See, for instance, benchmarks/share.txtar, where a simplified version of the Billion Laughs attack vector is evaluated in O(n) time, where n is the number of input nodes. In practice, there are many cases in CUE where repeated computation can be avoided, and structure sharing has been seen as one of the big wins to improve performance. Note that although structure sharing is purely meant as a performance improvement, it also alters computation order and it may cut evaluation short before tricky cycle situations are encountered. So it may fix some bugs as a side effect. Note that structure sharing may also interact with other performance improvements, resulting in compounding reductions. Note that although this change also largely makes structure sharing work with the API, it is mostly intended to make it work with the core evaluator only. We will still need to add thorough tests and evaluation of the API w.r.t. structure sharing. This is generally true for the new evaluator, so we plan to do this towards the end of its development. Issue #2884 Issue #2854 Signed-off-by: Marcel van Lohuizen <[email protected]> Change-Id: Ic1c888e9567242d6779093fcb391d6e001881f60
- Loading branch information
Showing
32 changed files
with
1,682 additions
and
3,715 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.