Resolver: Batched Import Resolution#145108
Resolver: Batched Import Resolution#145108LorrensP-2158466 wants to merge 2 commits intorust-lang:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
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. |
This comment has been minimized.
This comment has been minimized.
|
Okey, I did fix |
a3f8ae2 to
4a2a0dc
Compare
This comment has been minimized.
This comment has been minimized.
|
Could you update the tests to make CI green, so I can see the difference? |
|
Moving |
|
I'll create a pr for it. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Unblocked 🎉 |
|
Could you stash away the |
|
I stashed RustEmbed and addressed most of the comments, there is just a slight hiccup that i am not getting past atm. I'll explain on the relevant code. |
|
Here in rust/compiler/rustc_resolve/src/ident.rs Lines 1067 to 1086 in b6bed6f we introduce a "cycle detector" by getting an exclusive access on the In the case that the key exists in the This function is used here: rust/compiler/rustc_resolve/src/lib.rs Lines 2076 to 2086 in b6bed6f Which inserts an empty name resolution when it's not yet present, then combined with the exclusive access, we thus check cycles for new resolutions. But during speculative resolution, you can't mutably access the modules resolutions because it's wrapped in In serial execution, inserting an empty resolution doesn't really impact anything, but in parallel execution, this will cause a lot of locking. So question is, what should we do here? Because I don't know anything without introducing another structure that tracks which keys are being resolved (which in turn, introduces mutability and locking). Before your review, I also tried making this all work in parallel, where I stumbled on the exact same issue. I'll try and find a way out, let me know if you think of something. |
|
Let's keep an unchecked update there for now. |
This comment has been minimized.
This comment has been minimized.
|
Alright! Rebased to fix conflict and addressed review comments. @rustbot ready |
|
@rustbot ready |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (fa4dd1f): comparison URL. Overall result: ❌✅ regressions and improvements - no action neededBenchmarking 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 Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
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.
CyclesResults (primary -3.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 481.762s -> 496.521s (3.06%) |
|
Nice. |
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
This comment has been minimized.
This comment has been minimized.
|
🎉 Experiment
Footnotes
|
|
Looks like rust-embed is still a problem. |
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
|
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. |
|
Fixed conflicts, squashed and re-applied rust-embed fix. @rustbot ready |
| let res = binding.res().expect_non_local(); | ||
| if res != def::Res::Err { | ||
| let vis = match res.opt_def_id() { | ||
| Some(def_id) if self.macro_vis_hack_map.contains(&(module, def_id)) => { |
There was a problem hiding this comment.
I don't see why the intermediate macro_vis_hack_map is necessary, we can check all the conditions right here.
If
bindingis an import that refers to another import X- X is from macro_use_prelude and has name
RustEmbed modulehas a macro namespace binding Y with nameRustEmbedin it- Y is a glob import with public visibility
Then
- bump the
binding's visibility to public
|
☔ The latest upstream changes (presumably #153260) made this pull request unmergeable. Please resolve the merge conflicts. |
View all comments
Transforms the current algorithm for resolving imports to a batched algorithm. Every import in the
indeterminate_importsset is resolved in isolation. This is the only real difference from the current algorithm.r? petrochenkov