-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: Refactor PathTypeMention
#20094
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
Rust: Refactor PathTypeMention
#20094
Conversation
On databend this changes the number of `PathTypeMention`s from 3,777,464 to 3,330,024. Not a huge difference, but there's also downstream predicates that are reduced as well.
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 PathTypeMention
class in Rust code to improve performance and code organization. The refactoring introduces more selective path inclusion logic and separates handling of type aliases from other path types.
- Introduces a predicate to filter relevant path type mentions, excluding unnecessary cases like use statements
- Splits
PathTypeMention
into separate subclasses for alias and non-alias cases with distinct logic - Adds a new
resolveRootType
method to reduce recursion in type resolution
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
TypeInferenceConsistency.expected | Updates test expectations to reflect changes in type inference behavior |
TypeMention.qll | Refactors PathTypeMention into abstract base class with AliasPathTypeMention and NonAliasPathTypeMention subclasses |
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.
Well explained commit steps. 👍
DCA shows a 2% performance improvement.
🚀
I'm also pleased to see many less type inference inconsistencies.
There is zero change in resolved call targets except in rust where we loose 26 out of 355.248 targets. I haven't investigated why since: rust is a bit of a special case, there's no change on other projects, and the relative change it negligible.
We do unfortunately have some non-determinism in the Rust extractor, which manifests as wobble in DCA. Regardless of whether that's going on here, you're absolutely right this change is negligible.
This PR refactors
PathTypeMention
type mention:PathTypeMention
. Previously we would construct type mentions for some paths where this was not useful, for instance inuse
statements likeuse foo::bar::{SomePath};
.resolveRootType
is introduced which avoids some recursion.DCA shows a 2% performance improvement. There is zero change in resolved call targets except in
rust
where we loose 26 out of 355.248 targets. I haven't investigated why since:rust
is a bit of a special case, there's no change on other projects, and the relative change it negligible. But if anyone are curious I can absolutely take a look.