Skip to content

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

Merged
merged 5 commits into from
Jul 21, 2025

Conversation

paldepind
Copy link
Contributor

@paldepind paldepind commented Jul 19, 2025

This PR refactors PathTypeMention type mention:

  • We now only include relevant paths in PathTypeMention. Previously we would construct type mentions for some paths where this was not useful, for instance in use statements like use foo::bar::{SomePath};.
  • The handling of paths to aliases is moved to a separate subclass as the logic for the two cases is completely disjoint.
  • A new 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.

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.
@github-actions github-actions bot added the Rust Pull requests that update Rust code label Jul 19, 2025
@paldepind paldepind marked this pull request as ready for review July 21, 2025 06:43
@Copilot Copilot AI review requested due to automatic review settings July 21, 2025 06:43
@paldepind paldepind requested a review from a team as a code owner July 21, 2025 06:43
Copy link
Contributor

@Copilot Copilot AI left a 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

@paldepind paldepind added the no-change-note-required This PR does not need a change note label Jul 21, 2025
Copy link
Contributor

@geoffw0 geoffw0 left a 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.

@paldepind paldepind merged commit ad5c5ac into github:main Jul 21, 2025
20 of 21 checks passed
@paldepind paldepind deleted the rust/type-inference-path-mention branch July 21, 2025 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy