Skip to content

remove more trivial regions in evaluate_added_goals_and_make_canonical_response - #162032

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
sjwang05:more-region-dedup
Sep 6, 2026
Merged

remove more trivial regions in evaluate_added_goals_and_make_canonical_response#162032
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
sjwang05:more-region-dedup

Conversation

@sjwang05

@sjwang05 sjwang05 commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

View all comments

cc #161575. I don't think it fixes the issue per se, since the most principled fix would be to just deny unconstrained lifetime args like we do for types and consts already. At the very least, though, it Makes Things Go Faster.

In the example from #161575 (comment), each 'unconstrained appears only once in the entire response: in the rhs of the 'a: 'unconstrained#N bound. Since they are mentioned nowhere else and are created only when proving our own nested goals, these outlives constraints are all satisfiable by setting 'unconstrained := 'empty, which tells us nothing about 'a. Therefore, (I think) that makes it safe to treat all of these constraints as trivial and drop them entirely, drop all of these requirements entirely, similar to what we already do with reflexive or duplicate region constraints. In other words, if a ReVar appears only once in the entire response, and that place is the rhs of an outlives constraint, then it is safe to drop that constraint.

I'm a little worried about the perf impact of the visitor on "normal" code, but fwiw even a 100-deep nested version of the reproducer compiles in about 0.05s on my machine.

r? lcnr

@rustbot rustbot added 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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Aug 30, 2026
@sjwang05

sjwang05 commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Fun fact: the number of outlives constraints grows exactly as fib(2 * depth) :D

@rust-log-analyzer

This comment has been minimized.

@ShoyuVanilla

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 31, 2026
rust-bors Bot pushed a commit that referenced this pull request Aug 31, 2026
remove more trivial regions in evaluate_added_goals_and_make_canonical_response
Comment thread compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs Outdated
@rust-bors

rust-bors Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 0be4976 (0be497690edf5f58dfd2a6cfff82660c9c75ffa6)
Base parent: 5321a4f (5321a4f40c957cf3587c055e77461febc2ebc865)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (0be4976): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

This perf run didn't have relevant results for this metric.

Cycles

This perf run didn't have relevant results for this metric.

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: missing data
Artifact size: 402.71 MiB -> 402.86 MiB (0.04%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Aug 31, 2026
@Kobzol

Kobzol commented Aug 31, 2026

Copy link
Copy Markdown
Member

(Sorry, a rustc-perf failure, looking into it)

@ShoyuVanilla

Copy link
Copy Markdown
Member

Would rerunning with the same artifact make sense?

@Kobzol

Kobzol commented Aug 31, 2026

Copy link
Copy Markdown
Member

Yup, I deleted the result from the DB, and will rerun the artifact for you (once the underlying bug is fixed and deployed, which should happen in ~20 minutes).

@ShoyuVanilla

Copy link
Copy Markdown
Member

Yup, I deleted the result from the DB, and will rerun the artifact for you (once the underlying bug is fixed and deployed, which should happen in ~20 minutes).

Huge thanks! 😄

@Kobzol

Kobzol commented Aug 31, 2026

Copy link
Copy Markdown
Member

@rust-timer build 0be4976

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (0be4976): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (primary -1.8%, secondary -2.6%)

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)
-1.8% [-2.2%, -1.1%] 3
Improvements ✅
(secondary)
-2.6% [-3.6%, -1.2%] 4
All ❌✅ (primary) -1.8% [-2.2%, -1.1%] 3

Cycles

This perf run didn't have relevant results for this metric.

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 477.635s -> 477.178s (-0.10%)
Artifact size: 402.71 MiB -> 402.86 MiB (0.04%)

@rust-log-analyzer

This comment has been minimized.

Comment thread compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs
Comment thread compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs Outdated
@ShoyuVanilla

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 6, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 6, 2026
remove more trivial regions in evaluate_added_goals_and_make_canonical_response
@rust-bors

rust-bors Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 1ca580b (1ca580bb8c7d10c1e90e3221f9f7ab80d8fdd70c)
Base parent: f248f40 (f248f4038796913873f11ca65b1b901e311c8dae)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (1ca580b): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up.

@rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This perf run didn't have relevant results for this metric.

Max RSS (memory usage)

Results (primary -4.0%, secondary 7.0%)

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)
7.0% [7.0%, 7.0%] 1
Improvements ✅
(primary)
-4.0% [-4.0%, -4.0%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -4.0% [-4.0%, -4.0%] 1

Cycles

Results (primary 3.4%)

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

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

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 476.686s -> 484.632s (1.67%)
Artifact size: 403.40 MiB -> 403.41 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 6, 2026

@ShoyuVanilla ShoyuVanilla left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though there's no noticable change in perf, I think having less trivial bounds in the query output is generally good and the other points stated in the PR description make sense.

@bors r+

View changes since this review

@rust-bors

rust-bors Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

📌 Commit e9ab50c has been approved by ShoyuVanilla

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 6, 2026
@rust-bors

rust-bors Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

rust-bors Bot pushed a commit that referenced this pull request Sep 6, 2026
remove more trivial regions in evaluate_added_goals_and_make_canonical_response





cc #161575. I don't think it *fixes* the issue per se, since the most principled fix would be to just deny unconstrained lifetime args like we do for types and consts already. At the very least, though, it Makes Things Go Faster.

In the example from #161575 (comment), each `'unconstrained` appears only once in the entire response: in the rhs of the `'a: 'unconstrained#N` bound. Since they are mentioned nowhere else and are created only when proving our own nested goals, these outlives constraints are all satisfiable by setting `'unconstrained := 'empty`, which tells us nothing about `'a`. Therefore, (I think) that makes it safe to treat all of these constraints as trivial and drop them entirely, drop all of these requirements entirely, similar to what we already do with reflexive or duplicate region constraints. In other words, if a `ReVar` appears only once in the entire response, and that place is the rhs of an outlives constraint, then it is safe to drop that constraint.

I'm a little worried about the perf impact of the visitor on "normal" code, but fwiw even a 100-deep nested version of the reproducer compiles in about 0.05s on my machine.

r? lcnr
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors yield
Yielding to enclosing rollup

@rust-bors

rust-bors Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. Cancelled workflows:

The next pull request likely to be tested is #162362.

rust-bors Bot pushed a commit that referenced this pull request Sep 6, 2026
…uwer

Rollup of 4 pull requests

Successful merges:

 - #162032 (remove more trivial regions in evaluate_added_goals_and_make_canonical_response)
 - #161607 (Add #[track_caller] to signed integer div/rem methods)
 - #162339 (Revert "bootstrap: Enable rustdoc mergeable CCI for std and internal docs #161716")
 - #162158 (Revise documentation of `NumBuffer` and `format_into()`.)
@rust-bors
rust-bors Bot merged commit 45d62b0 into rust-lang:main Sep 6, 2026
14 of 15 checks passed
rust-bors Bot pushed a commit that referenced this pull request Sep 6, 2026
Rollup merge of #162032 - sjwang05:more-region-dedup, r=ShoyuVanilla

remove more trivial regions in evaluate_added_goals_and_make_canonical_response

cc #161575. I don't think it *fixes* the issue per se, since the most principled fix would be to just deny unconstrained lifetime args like we do for types and consts already. At the very least, though, it Makes Things Go Faster.

In the example from #161575 (comment), each `'unconstrained` appears only once in the entire response: in the rhs of the `'a: 'unconstrained#N` bound. Since they are mentioned nowhere else and are created only when proving our own nested goals, these outlives constraints are all satisfiable by setting `'unconstrained := 'empty`, which tells us nothing about `'a`. Therefore, (I think) that makes it safe to treat all of these constraints as trivial and drop them entirely, drop all of these requirements entirely, similar to what we already do with reflexive or duplicate region constraints. In other words, if a `ReVar` appears only once in the entire response, and that place is the rhs of an outlives constraint, then it is safe to drop that constraint.

I'm a little worried about the perf impact of the visitor on "normal" code, but fwiw even a 100-deep nested version of the reproducer compiles in about 0.05s on my machine.

r? lcnr
@rustbot rustbot added this to the 1.100.0 milestone Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants