resolve: Explicit Set for detecting resolution cycles#158035
resolve: Explicit Set for detecting resolution cycles#158035LorrensP-2158466 wants to merge 1 commit into
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. |
yes, that is not entirely correct, I think. this simple example: mod a {
pub use crate::b::X;
}
mod b {
pub use crate::a::X;
}Would have I am inclined to think that if both Edit: from debug: |
|
To clarify, by delaying the cycle check I also meant removing all the "is import" conditions. |
|
@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.
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+ |
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