Skip to content

Shrink mir::Statement to 40 bytes#159012

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
panstromek:make-stmtdebuginfos-smaller
Jul 11, 2026
Merged

Shrink mir::Statement to 40 bytes#159012
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
panstromek:make-stmtdebuginfos-smaller

Conversation

@panstromek

@panstromek panstromek commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

View all comments

We do this by using (old-style) ThinVec for storing debuginfo.

This collection is almost always empty, so we can optimize for that case. I think we could do better by storing the debuginfo elsewhere, but this is the least invasive change for now.

@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 9, 2026
@panstromek

Copy link
Copy Markdown
Contributor 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 Jul 9, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 9, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 5aa011a (5aa011acd7e9ca4e63fb318d6e94dbf24e019ec7)
Base parent: 561ea2b (561ea2bfa3022226082e2db39d6ccb241e9e34bc)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (5aa011a): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

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.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@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%] 5
Regressions ❌
(secondary)
0.5% [0.2%, 0.7%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.1% [-0.2%, -0.1%] 3
All ❌✅ (primary) 0.3% [0.2%, 0.3%] 5

Max RSS (memory usage)

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

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)
2.7% [2.7%, 2.7%] 1
Improvements ✅
(primary)
-1.4% [-2.5%, -0.6%] 37
Improvements ✅
(secondary)
-2.5% [-4.1%, -1.0%] 31
All ❌✅ (primary) -1.4% [-2.5%, -0.6%] 37

Cycles

Results (primary -2.9%)

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

Binary size

Results (primary 0.0%, secondary 0.0%)

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

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.1%] 2
Regressions ❌
(secondary)
0.0% [0.0%, 0.1%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.1%] 2

Bootstrap: 489.147s -> 487.269s (-0.38%)
Artifact size: 388.47 MiB -> 388.44 MiB (-0.01%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jul 9, 2026
@panstromek

Copy link
Copy Markdown
Contributor Author

Good Max RSS numbers, but I'm a bit confused by the unicode-normalization icount result. Debug-IncrFull is the one I was testing this on initially and it never actually pushes anything into the debuginfos list. Maybe I'm looking into this incorrectly, I'll try to figure out what's going on there.

@panstromek

panstromek commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Looks like this is just overhead of all the new management code (unicode-normalization truly never allocates anything there). I tried to put a few inlines where it helped based on cachegrind diffs. Let's see if it helps. if not, then I'll probably have to change strategy and move the branching out of the datastructure.

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

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 9, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: cc54650 (cc54650a1dcb449e1c44e013a4ffbf87f8d4895a)
Base parent: 3664b37 (3664b37017c529cad0f0ed259769f15743c21a6a)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (cc54650): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

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.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@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
Regressions ❌
(secondary)
0.3% [0.0%, 0.7%] 4
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.2% [-0.3%, -0.1%] 6
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary -1.3%, secondary -2.4%)

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.5% [3.5%, 3.5%] 1
Improvements ✅
(primary)
-1.3% [-2.4%, -0.6%] 29
Improvements ✅
(secondary)
-2.6% [-4.7%, -0.8%] 30
All ❌✅ (primary) -1.3% [-2.4%, -0.6%] 29

Cycles

Results (secondary -4.3%)

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

Binary size

Results (primary 0.0%, secondary 0.0%)

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

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.1%] 40
Regressions ❌
(secondary)
0.0% [0.0%, 0.1%] 26
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.1%] 40

Bootstrap: 487.967s -> 487.075s (-0.18%)
Artifact size: 388.37 MiB -> 388.36 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 9, 2026
@panstromek

Copy link
Copy Markdown
Contributor Author

This looks better. coercions and include-blob looks like bimodal noise. Max RSS gains persist. I'll clean this up a bit and undraft.

@panstromek

panstromek commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Actually, I want to try one more thing. Let's try to be a lot more aggressive about this inline/outline split. This reduced the overhead a bit in my local cachegrind measurements of unicode-normalization.

@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 Jul 10, 2026
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 10, 2026
@panstromek panstromek marked this pull request as ready for review July 11, 2026 06:20
@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 11, 2026
@rustbot

rustbot commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

r? @JohnTitor

rustbot has assigned @JohnTitor.
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
  • compiler, mir expanded to 75 candidates
  • Random selection from 19 candidates

@panstromek

Copy link
Copy Markdown
Contributor Author

Part of the icount result looks like noise (especially include-blob), but unicode-normalization and tuple-stress spends a lot of time in mir so at least part of it is probably legit. unicode-normalization also improved in my local cachegrind runs. max-rss improvements persist.

I squashed the commits and added a comment.

@panstromek panstromek changed the title shrink mir::Statement to 40 bytes Shrink mir::Statement to 40 bytes Jul 11, 2026
Comment thread compiler/rustc_middle/src/mir/statement.rs Outdated

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

Cool, r=me once addressing the typo above.

View changes since this review

We do this by using old-style ThinVec for storing debuginfos collection, which is almost always empty.
@panstromek panstromek force-pushed the make-stmtdebuginfos-smaller branch from 053c2b9 to 74dc8e7 Compare July 11, 2026 07:04
@panstromek

Copy link
Copy Markdown
Contributor Author

Done. I actually don't know whether I have rights to do this. Let's try.

@bors r=JohnTitor

@rust-bors

rust-bors Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

@panstromek: 🔑 Insufficient privileges: not in review users

@panstromek

Copy link
Copy Markdown
Contributor Author

Yea, I can't do this. @JohnTitor can you please r+ this yourself? Sorry for the churn.

@JohnTitor

Copy link
Copy Markdown
Member

Oh sorry I thought you had it...
Anyway, @bors r+

@rust-bors

rust-bors Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 74dc8e7 has been approved by JohnTitor

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

JonathanBrouwer commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

@bors rollup=iffy
Will to throw this into a small rollup as the perf effect is recognizable enough

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Jul 11, 2026
…ller, r=JohnTitor

Shrink mir::Statement to 40 bytes

We do this by using (old-style) ThinVec for storing debuginfo.

This collection is almost always empty, so we can optimize for that case. I think we could do better by storing the debuginfo elsewhere, but this is the least invasive change for now.
rust-bors Bot pushed a commit that referenced this pull request Jul 11, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #159126 (Fix PR number in bootstrap's change tracker)
 - #156968 (diagnostics: suggest generic_const_args for const ops)
 - #159012 (Shrink mir::Statement to 40 bytes)
 - #158182 (std: use `OnceLock` for SGX argument storage)
 - #159114 (Add regression test for $-prefixed fragment specifier in repetition)
 - #159060 (Look for the cdb architecture that corresponds to the target triple)
 - #159089 (riscv: update c-variadic test for LLVM changes)
 - #159093 (pretty-print: use inline asm's actual macro name)
rust-bors Bot pushed a commit that referenced this pull request Jul 11, 2026
…uwer

Rollup of 8 pull requests

Successful merges:

 - #159126 (Fix PR number in bootstrap's change tracker)
 - #156968 (diagnostics: suggest generic_const_args for const ops)
 - #159012 (Shrink mir::Statement to 40 bytes)
 - #158182 (std: use `OnceLock` for SGX argument storage)
 - #159114 (Add regression test for $-prefixed fragment specifier in repetition)
 - #159060 (Look for the cdb architecture that corresponds to the target triple)
 - #159089 (riscv: update c-variadic test for LLVM changes)
 - #159093 (pretty-print: use inline asm's actual macro name)
rust-bors Bot pushed a commit that referenced this pull request Jul 11, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #159126 (Fix PR number in bootstrap's change tracker)
 - #155811 (Include AtomicU128/AtomicI128 in docs for any target)
 - #156968 (diagnostics: suggest generic_const_args for const ops)
 - #159012 (Shrink mir::Statement to 40 bytes)
 - #156618 (rustdoc: test ignoring rustc lints in CLI)
 - #158182 (std: use `OnceLock` for SGX argument storage)
 - #159114 (Add regression test for $-prefixed fragment specifier in repetition)
 - #158523 (Fix feature gate for `repr(simd)`)
 - #158876 (Fix multiple logic bugs in `Arc::make_mut`)
 - #158928 (std: fix Xous UDP send_to length mismatch and truncation)
 - #159060 (Look for the cdb architecture that corresponds to the target triple)
 - #159089 (riscv: update c-variadic test for LLVM changes)
 - #159093 (pretty-print: use inline asm's actual macro name)
 - #159122 (doc: use ptr::addr in offset_from docs)

Failed merges:

 - #158732 (Apply MCP 1003 and move diagnostics.rs into its own module)
@rust-bors rust-bors Bot merged commit 8c60f8c into rust-lang:main Jul 11, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Jul 11, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

@rust-timer build ca5b0d2

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (ca5b0d2): 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.4% [0.4%, 0.4%] 1
Improvements ✅
(primary)
-0.3% [-0.3%, -0.3%] 2
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 1
All ❌✅ (primary) -0.3% [-0.3%, -0.3%] 2

Max RSS (memory usage)

Results (primary -1.3%, secondary -2.4%)

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.3% [-3.1%, -0.5%] 30
Improvements ✅
(secondary)
-2.4% [-3.9%, -0.9%] 28
All ❌✅ (primary) -1.3% [-3.1%, -0.5%] 30

Cycles

Results (secondary -2.7%)

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

Binary size

Results (primary 0.0%, secondary 0.0%)

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

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.1%] 2
Regressions ❌
(secondary)
0.0% [0.0%, 0.1%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [0.0%, 0.1%] 2

Bootstrap: 489.809s -> 489.264s (-0.11%)
Artifact size: 389.31 MiB -> 389.32 MiB (0.00%)

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