Rewrite maps, tuples, lists as BDDs. Performance improvements. #14693
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changing the representation of maps, tuples to instead use trees (binary decision diagrams).
As we use more and more the difference operator in the type system (e.g. to compute
fun_from_inferred_clauses(args_clauses)
for inferred function types from patterns), the "DNF" representation started running into pathological cases and hog out time during emptiness checks, and printing.The BDD is now used for set operations and subtyping, and translated (using previous logic and simplications) to DNF for printing and type operations like map fetch.
The BDD representation is common to maps, tuples, lists and functions. Some functions are generic (called bdd_difference, bdd_intersection, ...).
We also changes some algorithms:
tuple_eliminate_negation
was not generating disjoint tuples. It now does, which greatly improves performance and printing quality.-
tuple_empty?
now uses the same logic, this improves performances.pivot_overlapping_clauses
algorithm was not generating disjoint tuples. It now does.apply_disjoint
, when the functions are disjoint and non-empty (as produced by fun_from_inferred_clauses, for instance), which is much faster.