resolve: Explicit Set for detecting resolution cycles#158035
Conversation
This comment has been minimized.
This comment has been minimized.
1858b06 to
a2da807
Compare
|
It's clear that using a thread-local is more compact, but is it technically possible to pass the "active resolution" set explicitly as a parameter through all the relevant functions? We are already doing that for |
I will try it and see how it looks. |
|
To be honest, this gets quite cumbersome. There are a lot of functions that use the So now i have: pub(crate) fn maybe_resolve_ident_in_module<'r>(
// ...
cycle_detector: &mut ImportCycleDetector<'ra>,
){ ... }( But this detecting is not needed everywhere, so we could do this: pub(crate) fn maybe_resolve_ident_in_module<'r>(
// ...
cycle_detector: Option<&mut ImportCycleDetector<'ra>>,
){ ... }But then we require reborrowing in closures and loops, which is the same story as with So before I complete this big refactor i have 2 questions:
|
I think we need the cycle detector in exactly the same cases as |
|
@rustbot ready The cycle detector was also needed in macro resolution. |
This comment has been minimized.
This comment has been minimized.
3b561b9 to
d8e3473
Compare
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
So i reproduced that failing CI job locally to try and find the stack trace, here is the minimal version: So it does seem that infinite recursion can happen anywhere, anytime. If you think that the cycle_detector should still be an argument to these resolve calls, then I think its best to just have a separate argument, instead of combining it with |
|
Let's return to the (scoped) TLS approach and just keep doing what we do on the main branch. |
This comment has been minimized.
This comment has been minimized.
resolve: Explicit Set for detecting resolution cycles
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (b4f9537): comparison URL. Overall result: ❌ regressions - please read:Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. Next, please: If you can, justify the regressions found in this try perf run in writing along with @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 2.2%, secondary -3.8%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 3.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.1%, secondary -0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 486.982s -> 487.285s (0.06%) |
|
It looks acceptable now, |
…w_mut` on `RefCell<NameResolution>`. Use a TLS for this set ahead of parallel import resolution.
eb3318c to
3056b8e
Compare
|
Much better, indeed. squashed to 1 commit, @rustbot ready.
Can't do that :) |
|
@bors r+ |
|
❗ You can only retry pull requests that are approved and have a previously failed auto build. |
This comment has been minimized.
This comment has been minimized.
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 7dc2c16 (parent) -> 0966944 (this PR) Test differencesShow 12 test diffs12 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 096694416a41840709140eb0fd0ca193d1a3e6ba --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (0966944): comparison URL. Overall result: ❌ regressions - please read:Our benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression 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 3.2%, secondary 1.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis perf run didn't have relevant results for this metric. Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 511.037s -> 485.385s (-5.02%) |
View all comments
Instead of using the
borrow_mutcounter of aRefCellfor aNameResolutionfor detecting cyclic imports during import resolution, we use an explicit recursion stack that keeps track of the current usedNameResolutions.Because of the upcoming parallelisation of the import resolution algorithm, the current way cannot used in a parallel context.
r? @petrochenkov