Skip to content

Resolver: Batched Import Resolution#145108

Open
LorrensP-2158466 wants to merge 3 commits intorust-lang:mainfrom
LorrensP-2158466:batched-import-resolution
Open

Resolver: Batched Import Resolution#145108
LorrensP-2158466 wants to merge 3 commits intorust-lang:mainfrom
LorrensP-2158466:batched-import-resolution

Conversation

@LorrensP-2158466
Copy link
Contributor

@LorrensP-2158466 LorrensP-2158466 commented Aug 8, 2025

View all comments

Transforms the current algorithm for resolving imports to a batched algorithm. Every import in the indeterminate_imports set is resolved in isolation. This is the only real difference from the current algorithm.

r? petrochenkov

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 8, 2025
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@LorrensP-2158466 LorrensP-2158466 marked this pull request as ready for review August 11, 2025 08:37
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 11, 2025
@rust-log-analyzer

This comment has been minimized.

@petrochenkov petrochenkov added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 11, 2025
@LorrensP-2158466
Copy link
Contributor Author

LorrensP-2158466 commented Aug 11, 2025

Code looks a little better now and should be more correct than the previous commits, but I have yet to find a way to resolve the current test failures.

@rust-log-analyzer

This comment has been minimized.

@LorrensP-2158466
Copy link
Contributor Author

Okey, I did fix core not being built, but those other errors happened again. We now resolve the prelude import path when we create such an import at build_reduced_graph phase.

@LorrensP-2158466 LorrensP-2158466 force-pushed the batched-import-resolution branch from a3f8ae2 to 4a2a0dc Compare August 11, 2025 20:37
@rust-log-analyzer

This comment has been minimized.

@petrochenkov
Copy link
Contributor

Could you update the tests to make CI green, so I can see the difference?
(Even if the changes do not seem correct.)

@petrochenkov petrochenkov added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 12, 2025
@petrochenkov
Copy link
Contributor

Moving prelude_import processing to build_reduced_graph may also be necessary for #139493.

@LorrensP-2158466
Copy link
Contributor Author

I'll create a pr for it.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (fa4dd1f): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

@bors rollup=never
@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.2% [0.2%, 0.2%] 1
Regressions ❌
(secondary)
0.3% [0.2%, 0.7%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.8% [-0.8%, -0.8%] 1
All ❌✅ (primary) 0.2% [0.2%, 0.2%] 1

Max RSS (memory usage)

Results (primary -0.0%, secondary 3.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
1.6% [0.7%, 3.2%] 3
Regressions ❌
(secondary)
3.2% [2.1%, 4.8%] 3
Improvements ✅
(primary)
-2.4% [-2.9%, -2.0%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.0% [-2.9%, 3.2%] 5

Cycles

Results (primary -3.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.1% [-3.1%, -3.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -3.1% [-3.1%, -3.1%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 481.762s -> 496.521s (3.06%)
Artifact size: 397.93 MiB -> 397.97 MiB (0.01%)

@petrochenkov
Copy link
Contributor

Nice.
@craterbot check

@craterbot
Copy link
Collaborator

👌 Experiment pr-145108-2 created and queued.
🤖 Automatically detected try build fa4dd1f
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🚧 Experiment pr-145108-2 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@rust-bors

This comment has been minimized.

@craterbot
Copy link
Collaborator

🎉 Experiment pr-145108-2 is completed!
📊 161 regressed and 1 fixed (821749 total)
📊 2472 spurious results on the retry-regressed-list.txt, consider a retry1 if this is a significant amount.
📰 Open the summary report.

⚠️ If you notice any spurious failure please add them to the denylist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

Footnotes

  1. re-run the experiment with crates=https://crater-reports.s3.amazonaws.com/pr-145108-2/retry-regressed-list.txt

@petrochenkov
Copy link
Contributor

Looks like rust-embed is still a problem.
Could you rebase, squash commits and re-apply the rust-embed hack commit on top of the other changes?
@rustbot author

@rustbot

This comment has been minimized.

@LorrensP-2158466
Copy link
Contributor Author

Fixed conflicts, squashed and re-applied rust-embed fix. @rustbot ready

@rust-bors

This comment has been minimized.

Import resolution now happens in 2 phases:
1. We resolve all undetermined and collect their resolutions
2. Write all resolutions to the Resolver state.

Repeat this untill we reach a fix point.

+ Bless tests
@rustbot
Copy link
Collaborator

rustbot commented Mar 8, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@LorrensP-2158466
Copy link
Contributor Author

LorrensP-2158466 commented Mar 8, 2026

Rebased to fix the conflicts.

The rustembed hack is a bit more generic, than just checking for RustEmbed.

@rustbot ready

@petrochenkov
Copy link
Contributor

petrochenkov commented Mar 8, 2026

The rustembed hack is a bit more generic, than just checking for RustEmbed.

Here we need to address a specific set of regressions caused by one specific crate, not bend the language rules in general, the smaller the scope of the hack is the better.
The ambiguous_import_visibilities lint is the more generic solution.

@LorrensP-2158466
Copy link
Contributor Author

Yes, that's right, I forgot to make myself clear why I made it generic. I couldn't exactly find a way to these 2 points:

  • X is from macro_use_prelude and has name RustEmbed
  • module has a macro namespace binding Y with name RustEmbed in it

I couldn't exactly find a way to check exactly with the name RustEmbed. So I wanted to ask how I can search for a binding with identifier RustEmbed or check that X has such an identifier. Sorry

@LorrensP-2158466
Copy link
Contributor Author

Didn't know I could just add a new symbol, thanks!

@rustbot ready

@petrochenkov
Copy link
Contributor

@bors try

@rust-bors

This comment has been minimized.

@petrochenkov
Copy link
Contributor

TODO: @craterbot check p=1 crates=https://crater-reports.s3.amazonaws.com/pr-145108-2/retry-regressed-list.txt

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 11, 2026

☀️ Try build successful (CI)
Build commit: 0799524 (0799524677c1163b7afa649c7b4006f3d351a1c1, parent: b2fabe39bde5174e8d728bb85f2b8d0572c35b74)

@petrochenkov
Copy link
Contributor

@craterbot
Copy link
Collaborator

👌 Experiment pr-145108-3 created and queued.
🤖 Automatically detected try build 0799524
🔍 You can check out the queue and this experiment's details.

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🚧 Experiment pr-145108-3 is now running

ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

@craterbot
Copy link
Collaborator

🎉 Experiment pr-145108-3 is completed!
📊 31 regressed and 0 fixed (2551 total)
📊 179 spurious results on the retry-regressed-list.txt, consider a retry1 if this is a significant amount.
📰 Open the summary report.

⚠️ If you notice any spurious failure please add them to the denylist!
ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more

Footnotes

  1. re-run the experiment with crates=https://crater-reports.s3.amazonaws.com/pr-145108-3/retry-regressed-list.txt

@petrochenkov
Copy link
Contributor

Need regression analysis, each of the regressions need to fall under one of the deprecation lints we've merged recently.
I'll do it myself in a few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I-lang-radar Items that are on lang's radar and will need eventual work or consideration. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants