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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf-regression Performance regression. 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
6 participants