Skip to content

expand WF obligations when checking method calls #144704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 3, 2025

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Jul 30, 2025

Don't wrap a bunch of signatures in FnPtr then check their WF; instead, check the WFness of each input/output separately.

This is useful for the new trait solver, since because we stall on root obligations we end up needing to repeatedly recompute the WFness of possibly very large function signature types if it ends up bottoming out in ambiguity.

This may also give us more chances to hit the WF fast path for certain types like built-ins.

Finally, this just seems conceptually correct to do. There's nothing conceptually that suggests that wrapping the function signature in an fn pointer makes sense at all to do; I'm guessing that it was just convenient so that we didn't have to register WF obligations in a loop, but it doesn't affect the readability of this code at all.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 30, 2025
@compiler-errors
Copy link
Member Author

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Jul 30, 2025
expand WF obligations when checking method calls
@rust-bors
Copy link

rust-bors bot commented Jul 30, 2025

⌛ Trying commit 170ccbf with merge 732256d

To cancel the try build, run the command @bors try cancel.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 30, 2025
@rust-bors
Copy link

rust-bors bot commented Jul 30, 2025

☀️ Try build successful (CI)
Build commit: 732256d (732256d64d426bee934865a624326e817fab77ca, parent: e5e79f8bd428d0b8d26e8240d718b134ef297459)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (732256d): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking 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.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.3% [0.2%, 0.3%] 2
Regressions ❌
(secondary)
0.7% [0.1%, 1.1%] 10
Improvements ✅
(primary)
-0.2% [-0.4%, -0.2%] 19
Improvements ✅
(secondary)
-1.2% [-8.3%, -0.2%] 31
All ❌✅ (primary) -0.2% [-0.4%, 0.3%] 21

Max RSS (memory usage)

Results (primary -1.9%, secondary -2.2%)

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.9% [-2.8%, -0.9%] 2
Improvements ✅
(secondary)
-2.2% [-2.8%, -1.1%] 7
All ❌✅ (primary) -1.9% [-2.8%, -0.9%] 2

Cycles

Results (secondary -3.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)
4.4% [4.4%, 4.4%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.3% [-7.0%, -2.2%] 6
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 469.342s -> 468.025s (-0.28%)
Artifact size: 376.86 MiB -> 376.85 MiB (-0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jul 31, 2025
@compiler-errors
Copy link
Member Author

r? lcnr

@compiler-errors compiler-errors marked this pull request as ready for review July 31, 2025 13:19
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 31, 2025
@compiler-errors
Copy link
Member Author

The only major perf regression here is match-stress which seems somewhat unrelated and might just be noise (#144699 (comment)).

@lcnr
Copy link
Contributor

lcnr commented Jul 31, 2025

While these changes here are neutral to positive and I agree using an FnPtr type to represent arbitrary signatures is kinda iffy, it does make me a bit sad.

It seems to indicate that we're leaving a lot of perf on the table by not returning the stalled WellFormed(?leaf_infer) from the trait solver in general. I think that now that the root actually tracks recursion_limit per obligation anyway, it's not that hard to return nested goals. My only other concern is cycle handling/detection 🤔 I do believe that as long as we only ever return nested <infer-ty>: Trait or WellFormed(<infer-ty>) goals we're still gonna properly detect the cycles once that <infer-ty> is resolved, just with a potentially different root

edit: and diagnostics :3

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 31, 2025

📌 Commit 170ccbf has been approved by lcnr

It is now in the queue for this repository.

@bors bors 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 Jul 31, 2025
@bors
Copy link
Collaborator

bors commented Aug 3, 2025

⌛ Testing commit 170ccbf with merge 7cd9505...

@bors
Copy link
Collaborator

bors commented Aug 3, 2025

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing 7cd9505 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 3, 2025
@bors bors merged commit 7cd9505 into rust-lang:master Aug 3, 2025
12 checks passed
@rustbot rustbot added this to the 1.91.0 milestone Aug 3, 2025
Copy link
Contributor

github-actions bot commented Aug 3, 2025

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 da19b9d (parent) -> 7cd9505 (this PR)

Test differences

Show 2 test diffs

2 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 7cd950546b4ce68843b4cbdb1ab3a43776202d3a --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-aarch64-linux: 7830.8s -> 5634.6s (-28.0%)
  2. x86_64-apple-2: 5289.8s -> 4072.8s (-23.0%)
  3. aarch64-gnu-llvm-19-2: 2514.2s -> 2154.8s (-14.3%)
  4. pr-check-1: 1659.9s -> 1446.4s (-12.9%)
  5. pr-check-2: 2811.1s -> 2456.3s (-12.6%)
  6. aarch64-gnu: 7404.6s -> 6539.3s (-11.7%)
  7. x86_64-rust-for-linux: 2966.2s -> 2624.7s (-11.5%)
  8. aarch64-gnu-debug: 4267.2s -> 3823.9s (-10.4%)
  9. aarch64-gnu-llvm-19-1: 3819.9s -> 3444.6s (-9.8%)
  10. i686-gnu-2: 6022.3s -> 5438.7s (-9.7%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (7cd9505): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
0.4% [0.3%, 0.4%] 3
Regressions ❌
(secondary)
0.6% [0.2%, 1.1%] 12
Improvements ✅
(primary)
-0.2% [-0.4%, -0.2%] 19
Improvements ✅
(secondary)
-1.2% [-8.1%, -0.2%] 32
All ❌✅ (primary) -0.2% [-0.4%, 0.4%] 22

Max RSS (memory usage)

Results (primary -0.1%, secondary -1.7%)

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

mean range count
Regressions ❌
(primary)
5.4% [5.4%, 5.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.9% [-5.1%, -0.7%] 2
Improvements ✅
(secondary)
-1.7% [-2.4%, -0.9%] 7
All ❌✅ (primary) -0.1% [-5.1%, 5.4%] 3

Cycles

Results (primary -3.4%, secondary -7.2%)

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)
-3.4% [-3.4%, -3.4%] 1
Improvements ✅
(secondary)
-7.2% [-33.1%, -1.6%] 8
All ❌✅ (primary) -3.4% [-3.4%, -3.4%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 467.648s -> 468.551s (0.19%)
Artifact size: 376.99 MiB -> 376.95 MiB (-0.01%)

@nnethercote
Copy link
Contributor

Perf improvements greatly outweigh regressions.

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Aug 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants