-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Using lazy BDD structure for functions #14799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Lazy BDDS: ternary trees (instead of binary) where the additional node encodes a lazy union. See "COVARIANCE AND CONTRAVARIANCE: A FRESH LOOK AT AN OLD ISSUE"
lib/elixir/lib/module/types/descr.ex
Outdated
|
||
# Optional guard: blow up if someone passes a binary node by mistake | ||
defp lazy_bdd_to_dnf(_acc, _pos, _neg, {_lit, _t, _e}) do | ||
raise ArgumentError, "lazy_bdd_to_dnf expects lazy nodes {lit, c, u, d}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to just remove the clause or add the value in the error message for debugging?
raise ArgumentError, "lazy_bdd_to_dnf expects lazy nodes {lit, c, u, d}" | |
raise ArgumentError, "lazy_bdd_to_dnf expects lazy nodes {lit, c, u, d}, got: #{inspect(tuple)}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove once I have really made sure this case cannot happen (I have just noticed this clause hits when compiling HexPm)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, it all compiles well, this was a cache issue!
end | ||
end | ||
|
||
def lazy_bdd_union(bdd1, bdd2) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to make all of them private :)
Now it only seems to appear in artificial examples.
Remark: best 1.19 performance, similar to 1.18 speed!
end | ||
|
||
@compile {:inline, map_union: 2} | ||
def map_union(bdd1, bdd2), do: bdd_union(bdd1, bdd2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def map_union(bdd1, bdd2), do: bdd_union(bdd1, bdd2) | |
defp map_union(bdd1, bdd2), do: bdd_union(bdd1, bdd2) |
end | ||
end | ||
|
||
## Lazy BDD helpers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
## Lazy BDD helpers | |
## Lazy BDD helpers | |
@compile {:inline, lazy_bdd_new: 1, lazy_bdd_new: 3} |
From p.35 of https://www.irif.fr/~gc/papers/covcon-again.pdf
This improves consecutive unions of function types greatly.
This also solves the long compilation time for Spitfire encountered in #14693