Prevent very long compilation runtimes in LateBoundRegionNameCollector#83406
Prevent very long compilation runtimes in LateBoundRegionNameCollector#83406bors merged 1 commit intorust-lang:masterfrom
Conversation
|
r? @lcnr (rust-highfive has picked a reviewer for you, use r? to override) |
src/test/ui/recursion/issue-83150.rs
Outdated
There was a problem hiding this comment.
This test passes for an unexplainable reason. When I compile this file I get the expected error:
error[E0275]: overflow evaluating the requirement `Map<&mut Map<&mut Map<&mut Map<&mut Map<.....
But the test suite cannot find an error.
There was a problem hiding this comment.
i expect you to need at least // build-pass here, as the overly large types should only get created during mono item collection
This comment has been minimized.
This comment has been minimized.
lcnr
left a comment
There was a problem hiding this comment.
I don't think that using type length limit is the best approach here.
The issue here is that the type T is &mut Map<T_prev, closure [T_prev]> so the type size scales by 2^depth instead of just depth.
Using https://doc.rust-lang.org/nightly/nightly-rustc/rustc_data_structures/sso/struct.SsoHashSet.html in visit_ty seems like a potentially better solution to me
src/test/ui/recursion/issue-83150.rs
Outdated
There was a problem hiding this comment.
i expect you to need at least // build-pass here, as the overly large types should only get created during mono item collection
There was a problem hiding this comment.
infinitely recursed types
nit: there are no infinite types. Types are finite trees, so infinite types are impossible.
We can get very large types though, which causes the hang here.
|
@lcnr Thanks for the review. I don't understand how you would want to use |
|
I don't want to break control at all here. Afaict this is not an infinite hang, this is a finite, but incredibly large perf regression. I want to use a |
|
@lcnr Thanks, that clarifies things. You're right, this isn't a hang. I updated the PR to use the |
This comment has been minimized.
This comment has been minimized.
|
There's also a problem with another test, seems as if `LateBoundRegionNameCollector' has different functionality if we skip types we've seen before. |
|
@lcnr Can you take another look? What do we do about the tests? |
This comment has been minimized.
This comment has been minimized.
|
i think the correct attribute here is |
|
@lcnr Yes, that's the correct attribute. Thanks for the review and the help. |
There was a problem hiding this comment.
| type_collector: SsoHashSet::with_capacity(1000), | |
| type_collector: SsoHashSet::new(), |
we don't want to allocate here by default.
src/test/ui/recursion/issue-83150.rs
Outdated
There was a problem hiding this comment.
| //~^ overflow evaluating | |
| //~^ overflow evaluating |
|
please update the PR name and description, then this should be ready after a perf run. |
|
@lcnr This is ready for the perf run. |
|
☔ The latest upstream changes (presumably #76814) made this pull request unmergeable. Please resolve the merge conflicts. |
|
@bors try @rust-timer queue |
|
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
|
⌛ Trying commit 3194b26 with merge 9fb1f198bce56ca989b0203c337bedffb89b96a1... |
|
☀️ Try build successful - checks-actions |
|
Queued 9fb1f198bce56ca989b0203c337bedffb89b96a1 with parent b1b0a15, future comparison URL. |
|
Finished benchmarking try commit (9fb1f198bce56ca989b0203c337bedffb89b96a1): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
|
@bors r+ |
|
📌 Commit 3194b26 has been approved by |
|
☀️ Test successful - checks-actions |
|
Should this be backported to 1.52? @rust-lang/compiler Context: this fixes a t-hang stable-to-stable regression that has been reported multiple times caused by big type names, the latest report being #84102 |
Fixes #83150
On recursive types such as in the example given in #83150, the current implementation of
LateBoundRegionNameCollectorhas very long compilation runtimes. To prevent those we store the types visited in themiddle::ty::Visitorimplementation ofLateBoundRegionNameCollectorin aSsoHashSet.