Skip to content

Cache block seeking results for initialized_at_terminator and _exit - #162450

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
jackh726:polonius-cleanups-4
Sep 17, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
jackh726:polonius-cleanups-4

Conversation

@jackh726

@jackh726 jackh726 commented Sep 8, 2026

Copy link
Copy Markdown
Member

Caching the block values post-seek results in significant performance wins (especially on pathological benchmarks). These wins extend to NLL, too.

Possibly, this caching could be done further up the stack (more generically), but figured this is a "safer" approach - rather than dealing with other potential fallout.

r? lqd

LLM-generated perf summary table image

@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 Sep 8, 2026
@jackh726

jackh726 commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

Disclosure: An LLM was used to identify this perf effect and to check the performance of the solution.

@jackh726

jackh726 commented Sep 8, 2026

Copy link
Copy Markdown
Member Author

@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 8, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Sep 8, 2026
Cache block seeking results for initialized_at_terminator and _exit
Comment on lines +308 to +312
if self.cx.initialized_at_terminator(location.block, mpi) {
let inserted = self.drop_live_at.insert(drop_point);
// Right now, we should visit a drop_point twice.
// If we do, this trigger a debug assert so we need we can optimize.
debug_assert!(inserted, "drop point should not have been visited yet");

@jackh726 jackh726 Sep 8, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is technically completely unrelated - but sticking it in as a drive-by pass. I had a though that we might be visiting drop points twice (and thus could switch these conditions for a perf benefit) - but the iteration here is unique.

View changes since the review

Comment thread compiler/rustc_borrowck/src/type_check/liveness/trace.rs Outdated
Comment thread compiler/rustc_borrowck/src/type_check/liveness/trace.rs Outdated
Comment thread compiler/rustc_borrowck/src/type_check/liveness/trace.rs Outdated
@rust-bors

rust-bors Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 2bf7717 (2bf77177e903bc66ebe183042d1ad525545e866a)
Base parent: 2e6e39f (2e6e39f684e1c6b0bbfe16593a23d901e61219ca)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (2bf7717): comparison URL.

Overall result: ✅ improvements - no action needed

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

@bors rollup=never rustc-perf
@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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.1% [-5.7%, -0.2%] 9
Improvements ✅
(secondary)
-4.1% [-5.7%, -0.2%] 10
All ❌✅ (primary) -3.1% [-5.7%, -0.2%] 9

Max RSS (memory usage)

Results (primary -0.4%)

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

mean range count
Regressions ❌
(primary)
0.5% [0.5%, 0.5%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.7% [-1.4%, -0.4%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.4% [-1.4%, 0.5%] 4

Cycles

Results (primary -1.4%, secondary -0.3%)

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

mean range count
Regressions ❌
(primary)
0.4% [0.4%, 0.4%] 1
Regressions ❌
(secondary)
3.7% [3.7%, 3.7%] 1
Improvements ✅
(primary)
-1.8% [-2.6%, -0.7%] 4
Improvements ✅
(secondary)
-2.2% [-2.4%, -2.1%] 2
All ❌✅ (primary) -1.4% [-2.6%, 0.4%] 5

Binary size

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

Bootstrap: 482.327s -> 479.101s (-0.67%)
Artifact size: 403.54 MiB -> 403.54 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 8, 2026
Comment thread compiler/rustc_borrowck/src/type_check/liveness/trace.rs Outdated
@rust-cloud-vms
rust-cloud-vms Bot force-pushed the polonius-cleanups-4 branch 4 times, most recently from 9664d1b to a18e438 Compare September 16, 2026 16:12
@lqd

lqd commented Sep 16, 2026

Copy link
Copy Markdown
Member

Beautiful.

@bors r+ rollup=never

@rust-bors

rust-bors Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

📌 Commit bbfef75 has been approved by lqd

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 16, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors rollup=iffy
Making a rollup of perf-sensitive PRs

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

Rollup of 4 perf-sensitive pull requests

Successful merges:

 - #162450 (Cache block seeking results for initialized_at_terminator and _exit)
 - #162543 ([rustc_resolve]  Correctly keep all reexports in `ModChild::reexport_chain`)
 - #162712 (perf: Keep the first macro syntax-context mapping inline)
 - #162747 (Lowering cleanups)
rust-bors Bot pushed a commit that referenced this pull request Sep 16, 2026
…uwer

Rollup of 4 perf-sensitive pull requests

Successful merges:

 - #162450 (Cache block seeking results for initialized_at_terminator and _exit)
 - #162543 ([rustc_resolve]  Correctly keep all reexports in `ModChild::reexport_chain`)
 - #162712 (perf: Keep the first macro syntax-context mapping inline)
 - #162747 (Lowering cleanups)
@rust-bors

rust-bors Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

⌛ Testing commit bbfef75 with merge 40e5555...

Workflow: https://github.com/rust-lang/rust/actions/runs/35165799977

rust-bors Bot pushed a commit that referenced this pull request Sep 17, 2026
Cache block seeking results for initialized_at_terminator and _exit

Caching the block values post-seek results in significant performance wins (especially on pathological benchmarks). These wins extend to NLL, too.

Possibly, this caching could be done further up the stack (more generically), but figured this is a "safer" approach - rather than dealing with other potential fallout.

r? lqd
@Zalathar

Copy link
Copy Markdown
Member

@bors yield (to enclosing perf-sensitive rollup)

@rust-bors

rust-bors Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Auto build was cancelled. Cancelled workflows:

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

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

Rollup of 4 perf-sensitive pull requests

Successful merges:

 - #162450 (Cache block seeking results for initialized_at_terminator and _exit)
 - #162543 ([rustc_resolve]  Correctly keep all reexports in `ModChild::reexport_chain`)
 - #162712 (perf: Keep the first macro syntax-context mapping inline)
 - #162747 (Lowering cleanups)
rust-bors Bot pushed a commit that referenced this pull request Sep 17, 2026
…uwer

Rollup of 4 perf-sensitive pull requests



Successful merges:

 - #162450 (Cache block seeking results for initialized_at_terminator and _exit)
 - #162543 ([rustc_resolve]  Correctly keep all reexports in `ModChild::reexport_chain`)
 - #162712 (perf: Keep the first macro syntax-context mapping inline)
 - #162747 (Lowering cleanups)
rust-bors Bot pushed a commit that referenced this pull request Sep 17, 2026
Rollup merge of #162450 - jackh726:polonius-cleanups-4, r=lqd

Cache block seeking results for initialized_at_terminator and _exit

Caching the block values post-seek results in significant performance wins (especially on pathological benchmarks). These wins extend to NLL, too.

Possibly, this caching could be done further up the stack (more generically), but figured this is a "safer" approach - rather than dealing with other potential fallout.

r? lqd
@rust-bors
rust-bors Bot merged commit 99aea09 into rust-lang:main Sep 17, 2026
13 of 14 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 17, 2026
@rust-timer

Copy link
Copy Markdown
Collaborator

Note

This PR was benchmarked as part of triage of its containing rollup: triage URL.

Finished benchmarking commit (89b0093): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-4.5% [-5.8%, -3.6%] 12
Improvements ✅
(secondary)
-4.6% [-5.3%, -4.0%] 3
All ❌✅ (primary) -4.5% [-5.8%, -3.6%] 12

Max RSS (memory usage)

Results (primary -3.1%, secondary 3.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)
3.2% [2.3%, 4.0%] 2
Improvements ✅
(primary)
-3.1% [-4.2%, -2.3%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -3.1% [-4.2%, -2.3%] 3

Cycles

Results (primary 0.5%)

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

mean range count
Regressions ❌
(primary)
2.0% [1.7%, 2.4%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.5% [-2.5%, -2.5%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.5% [-2.5%, 2.4%] 3

Binary size

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

Bootstrap: missing data
Artifact size: 406.75 MiB -> 406.83 MiB (0.02%)

@jackh726
jackh726 deleted the polonius-cleanups-4 branch September 17, 2026 12:15
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants