-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Type intersection sometimes takes several seconds #48821
Comments
Turns out it's not the tuple combinatorics in this case: This comes from the double-intersection we evaluate in Lines 2913 to 2932 in a23b29c
This becomes |
My first stab at this was to statically adjust our types to reduce type-var nesting, while preserving type-equality. Unfortunately, our current intersection algorithm will widen when you do this:
Subtyping even becomes incorrect under this transformation (which should preserve type-equality):
|
The widening is expected. |
Thanks for the info! That's helpful historical information. It's a shame that in this case it ends up opting into an exponential algorithm even when it's often not necessary, but I suppose the whole problem here is that the intersection algorithm is not good at dynamically expanding/shrinking UnionAll dependencies (based on the chains of type-vars considered) I'm going to take a stab at solving this dynamically (by narrowing dependencies during intersection computation), rather than statically (with a type transformation) |
Seems to happen when intersecting extremely large tuples.
50+s example from BlochSim.jl:
20+s example from StochasticDiffEq.jl:
Version:
I expect that we're going down a combinatorial path among all the tuple components, despite the fact that they don't actually share any typevars.
Fix is in the works 🙂
The text was updated successfully, but these errors were encountered: