-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: Type inference refactor and improve join orders #20076
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
…` are in `relevantConstraint`
… and factor out `multipleConstraintImplementations`
c00cf2f
to
43b2977
Compare
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.
Pull Request Overview
This PR refactors the Rust type inference library to improve join orders and reduce computational overhead. The changes focus on optimizing predicate evaluation and streamlining constraint satisfaction logic.
Key changes:
- Extracted
multipleConstraintImplementations
predicate to improve reusability and join ordering - Moved
hasTypeConstraint
predicate definition earlier for better join optimization - Simplified
typeParameterConstraintHasTypeParameter
predicate by reducing unnecessary joins and intermediate variables
typeParameterConstraintHasTypeParameter(target, dpos, path, _, constraint, _, _) | ||
) | ||
target = a.getTarget() and | ||
typeParameterConstraintHasTypeParameter(target, apos, path, constraint, _, _) |
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.
The predicate call has mismatched parameter count. Based on the definition at line 1393, typeParameterConstraintHasTypeParameter
expects 6 parameters but only 6 are provided here. However, the parameter order appears incorrect - apos
should correspond to AccessPosition
but the definition expects DeclarationPosition
to be resolved from it internally.
Copilot uses AI. Check for mistakes.
@@ -989,7 +996,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> { | |||
path = prefix0.append(suffix) | |||
) | |||
or | |||
tt.getTypeAt(TypePath::nil()) = constraint and | |||
hasTypeConstraint(tt, constraint, constraint) and |
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.
The crux here is hat hasTypeConstraint
includes relevantConstraint
. Before that this disjunct allowed constraint
to be anything tt.getTypeAt(TypePath::nil())
which caused the relation to contain a lot of junk.
This PR makes a few refactors to the type inference library.
I think these changes make sense on their own, but on
databend
they also reduce the total number of tuples (observed using "Compare Performance" in VSCode) and the following bad join reported by VScode (also observed ondatabend
) disappears:Bad join
DCA is uneventful and don't show any change in analysis time 😢