Skip to content

MirPatch: reduce new statement insertion complexity - #165913

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
tmiasko:patch
Nov 19, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
tmiasko:patch

Conversation

@tmiasko

@tmiasko tmiasko commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

The previous implementation inserted each new statement in a block separately, which in the worst case moved all existing statements each time.

Use a simple merging strategy to improve complexity from O(num existing statements × num new statements) to O(num existing statements + num new statements).

Helps with #121354.

@rustbot

rustbot commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@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 Nov 13, 2026
@rustbot

rustbot commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

r? @mu001999

rustbot has assigned @mu001999.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, mir, mir-opt
  • compiler, mir, mir-opt expanded to 79 candidates
  • Random selection from 19 candidates

@tmiasko

tmiasko commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@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 Nov 13, 2026
@rust-log-analyzer

This comment has been minimized.

@tmiasko

tmiasko commented Nov 13, 2026

Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Nov 13, 2026
MirPatch: reduce new statement insertion complexity
@rust-bors

rust-bors Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: ec11aa8 (ec11aa82b0f166bdb85468aca9a8827ef2f4ab47)
Base parent: d362215 (d3622156fd2c96d8653efd3868341978763d63bc)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown

Finished benchmarking commit (ec11aa8): comparison URL.

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

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

Max RSS (memory usage)

Results (secondary 5.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)
5.2% [5.2%, 5.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

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

Binary size

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

Bootstrap: 483.169s -> 486.028s (0.59%)
Artifact size: 406.05 MiB -> 406.18 MiB (0.03%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 13, 2026
The previous implementation inserted each new statement in a block
separately, which in the worst case moved all existing statements each
time.

Use a simple merging strategy to improve complexity from
O(num existing statements × num new statements) to
O(num existing statements + num new statements).
@mu001999

Copy link
Copy Markdown
Member

@rustbot reroll

@rustbot rustbot assigned jieyouxu and unassigned mu001999 Nov 17, 2026
@dianqk

dianqk commented Nov 17, 2026

Copy link
Copy Markdown
Member

r? dianqk

@rustbot rustbot assigned dianqk and unassigned jieyouxu Nov 17, 2026

@dianqk dianqk 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.

@dianqk

dianqk commented Nov 18, 2026

Copy link
Copy Markdown
Member

@bors r+

@rust-bors

rust-bors Bot commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

📌 Commit b7ed414 has been approved by dianqk

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 Nov 18, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 18, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #165913 (MirPatch: reduce new statement insertion complexity)
 - #166081 (test `feature(asm_const_ptr)` with a vtable)
 - #166094 (Chain the spans of qualified paths instead of having a first-to-last scheme )
 - #166113 (Fix dead-code marking dead enum variants as live)
 - #166118 (rustc_target: catch up with LLVM 24 movement on ppc64le bsd data layout)
 - #166155 (windows seek_write: document interaction with append mode)
 - #165935 (Duplicate attribute diagnostic cleanups)
 - #165948 (lint: Avoid unused_parens warning for ref patterns binding an identifier)
 - #166018 (`rustc_mir_build`: de-duplicate `local_temp_lifetime()`)
 - #166111 (Add `cd` alias to `std::env::set_current_dir`)
 - #166157 (Don't recover invalid literals in attribute parsing)
rust-bors Bot pushed a commit that referenced this pull request Nov 19, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #165913 (MirPatch: reduce new statement insertion complexity)
 - #166081 (test `feature(asm_const_ptr)` with a vtable)
 - #166094 (Chain the spans of qualified paths instead of having a first-to-last scheme )
 - #166113 (Fix dead-code marking dead enum variants as live)
 - #166118 (rustc_target: catch up with LLVM 24 movement on ppc64le bsd data layout)
 - #166155 (windows seek_write: document interaction with append mode)
 - #165935 (Duplicate attribute diagnostic cleanups)
 - #165948 (lint: Avoid unused_parens warning for ref patterns binding an identifier)
 - #166018 (`rustc_mir_build`: de-duplicate `local_temp_lifetime()`)
 - #166111 (Add `cd` alias to `std::env::set_current_dir`)
 - #166157 (Don't recover invalid literals in attribute parsing)
rust-bors Bot pushed a commit that referenced this pull request Nov 19, 2026
Rollup merge of #165913 - tmiasko:patch, r=dianqk

MirPatch: reduce new statement insertion complexity

The previous implementation inserted each new statement in a block separately, which in the worst case moved all existing statements each time.

Use a simple merging strategy to improve complexity from O(num existing statements × num new statements) to O(num existing statements + num new statements).

Helps with #121354.
@rust-bors
rust-bors Bot merged commit fbeaa76 into rust-lang:main Nov 19, 2026
14 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 19, 2026
@tmiasko
tmiasko deleted the patch branch November 19, 2026 21:56
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.

7 participants