Skip to content

borrowck nested items in dead code #140590

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
May 7, 2025
Merged

Conversation

lcnr
Copy link
Contributor

@lcnr lcnr commented May 2, 2025

@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. labels May 2, 2025
@lcnr
Copy link
Contributor Author

lcnr commented May 2, 2025

@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 May 2, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request May 2, 2025
borrowck nested items in dead code

fixes rust-lang#140583

r? `@compiler-errors`
@bors
Copy link
Collaborator

bors commented May 2, 2025

⌛ Trying commit 8659c5f with merge 44541a5...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented May 2, 2025

☀️ Try build successful - checks-actions
Build commit: 44541a5 (44541a5256c7929fb92abebc7ef12b7851700767)

@rust-timer

This comment has been minimized.

@rust-cloud-vms rust-cloud-vms bot force-pushed the closure-in-dead-code branch from 8659c5f to ffa7d1e Compare May 2, 2025 18:45
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (44541a5): comparison URL.

Overall result: ❌ regressions - please read the text below

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

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

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
0.5% [0.2%, 3.0%] 14
Regressions ❌
(secondary)
0.4% [0.0%, 1.1%] 21
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.5% [0.2%, 3.0%] 14

Max RSS (memory usage)

Results (primary 0.7%, secondary 2.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.1% [0.4%, 7.3%] 37
Regressions ❌
(secondary)
4.2% [0.9%, 7.4%] 7
Improvements ✅
(primary)
-0.8% [-2.6%, -0.4%] 10
Improvements ✅
(secondary)
-2.9% [-3.3%, -2.4%] 2
All ❌✅ (primary) 0.7% [-2.6%, 7.3%] 47

Cycles

Results (primary 0.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.8% [0.4%, 3.1%] 31
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.4%, -0.4%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.7% [-0.4%, 3.1%] 32

Binary size

Results (primary 1.1%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

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

Bootstrap: 766.288s -> 769.539s (0.42%)
Artifact size: 365.55 MiB -> 365.43 MiB (-0.03%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels May 2, 2025
@lcnr
Copy link
Contributor Author

lcnr commented May 3, 2025

Okay, so clap_derive seems bimodal to me. It now spends more time in llvm. The other 0.5% regression seem to be caused by evaluating the nested_bodies_within query.

#138499 was a 1.4% improvement in issue-88862. We don't fully lose that perf gain again. This benchmark has one closure in dead code, so this is expected https://github.com/rust-lang/rustc-perf/blob/18437e0d5ff596de62047b0697b6ce9f2be1b4f5/collector/compile-benchmarks/issue-88862/src/main.rs#L38-L39.

The remaining regressions are ~0.5% in bitmaps and libc. I would expect that both these crates have a lot of small functions, so calling one more query per function body is actually noticeable? 🤔

Making it less expensive seems difficult. We could separately collect all closures by walking the MIR body right after MIR build, similar to required_consts 🤔

@lcnr
Copy link
Contributor Author

lcnr commented May 3, 2025

I've talked with @compiler-errors about this in person, and the small perf hit of computing nested_bodies_within will be necessary to stabilize the new solver regardless, as TypingMode::typeck_for_body will also need to rely on this query.

@compiler-errors
Copy link
Member

Yeah, I think this is necessary and worth the perf hit. The nested_bodies_within query could be optimized if we had some efficient way of getting a DefId -> [DefId] parent to child mapping, but AFAICT we don't have that.

@bors r+ rollup=never

@bors
Copy link
Collaborator

bors commented May 5, 2025

📌 Commit ffa7d1e has been approved by compiler-errors

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 May 5, 2025
@bors
Copy link
Collaborator

bors commented May 7, 2025

⌛ Testing commit ffa7d1e with merge e9f8103...

@bors
Copy link
Collaborator

bors commented May 7, 2025

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing e9f8103 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 7, 2025
@bors bors merged commit e9f8103 into rust-lang:master May 7, 2025
7 checks passed
@rustbot rustbot added this to the 1.88.0 milestone May 7, 2025
Copy link

github-actions bot commented May 7, 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 3ef8e64 (parent) -> e9f8103 (this PR)

Test differences

Show 2 test diffs

Stage 1

  • [ui] tests/ui/nll/nested-bodies-in-dead-code.rs: [missing] -> pass (J0)

Stage 2

  • [ui] tests/ui/nll/nested-bodies-in-dead-code.rs: [missing] -> pass (J1)

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard e9f8103f93f8ce2fa2c15c0c6796ec821f8ae15d --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-x86_64-apple: 11149.8s -> 6942.1s (-37.7%)
  2. dist-s390x-linux: 5225.9s -> 6938.4s (32.8%)
  3. dist-aarch64-apple: 5794.5s -> 4597.0s (-20.7%)
  4. dist-arm-linux: 4400.3s -> 5295.2s (20.3%)
  5. x86_64-apple-1: 7342.4s -> 8624.1s (17.5%)
  6. x86_64-apple-2: 4950.9s -> 4109.9s (-17.0%)
  7. dist-apple-various: 9319.7s -> 7993.3s (-14.2%)
  8. aarch64-apple: 4852.3s -> 4373.2s (-9.9%)
  9. x86_64-gnu-llvm-20-3: 7341.1s -> 6786.3s (-7.6%)
  10. dist-aarch64-msvc: 9029.8s -> 8487.3s (-6.0%)
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 (e9f8103): comparison URL.

Overall result: ❌ regressions - 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

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

mean range count
Regressions ❌
(primary)
0.3% [0.2%, 0.5%] 29
Regressions ❌
(secondary)
0.6% [0.2%, 1.5%] 24
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.2%, 0.5%] 29

Max RSS (memory usage)

Results (primary 1.0%, secondary 3.2%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.2% [0.4%, 7.6%] 53
Regressions ❌
(secondary)
4.6% [1.4%, 7.9%] 10
Improvements ✅
(primary)
-0.9% [-1.1%, -0.7%] 4
Improvements ✅
(secondary)
-4.0% [-4.8%, -3.3%] 2
All ❌✅ (primary) 1.0% [-1.1%, 7.6%] 57

Cycles

Results (primary 0.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.8% [0.5%, 1.0%] 15
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.5% [-0.5%, -0.4%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.7% [-0.5%, 1.0%] 17

Binary size

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

Bootstrap: 770.356s -> 769.783s (-0.07%)
Artifact size: 365.20 MiB -> 365.19 MiB (-0.00%)

@lcnr lcnr deleted the closure-in-dead-code branch May 8, 2025 02:09
@panstromek
Copy link
Contributor

perf triage:

regression is expected and justified, based on the comments above (#140590 (comment) and #140590 (comment)).

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label May 12, 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.

closures in dead code are no longer borrowchecked
7 participants