Skip to content

shrink mir::Statement to 40 bytes#159012

Draft
panstromek wants to merge 1 commit into
rust-lang:mainfrom
panstromek:make-stmtdebuginfos-smaller
Draft

shrink mir::Statement to 40 bytes#159012
panstromek wants to merge 1 commit into
rust-lang:mainfrom
panstromek:make-stmtdebuginfos-smaller

Conversation

@panstromek

Copy link
Copy Markdown
Contributor

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

From what I can tell using some basic eprintln! measurements, the debuginfos collection is almost always empty.

We do this by using old-style ThinVec for storing debuginfo
@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

Copy link
Copy Markdown
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Diff in /checkout/compiler/rustc_middle/src/mir/statement.rs:1053:
     pub fn is_empty(&self) -> bool {
         match &self.0 {
             None => true,
-            Some(v) => v.is_empty()
+            Some(v) => v.is_empty(),
         }
     }
 
Diff in /checkout/compiler/rustc_middle/src/mir/statement.rs:1088:
     pub fn as_mut_slice(&mut self) -> &mut [StmtDebugInfo<'tcx>] {
         match self.0.as_mut() {
             None => &mut [],
-            Some(items) => items.as_mut_slice()
+            Some(items) => items.as_mut_slice(),
         }
     }
 
Diff in /checkout/compiler/rustc_middle/src/mir/statement.rs:1095:
     pub fn retain_locals(&mut self, locals: &DenseBitSet<Local>) {
         match &mut self.0 {
             None => (),
-            Some(items) => {
-                items.retain(|debuginfo| match debuginfo {
-                    StmtDebugInfo::AssignRef(local, _) | StmtDebugInfo::InvalidAssign(local) => {
-                        locals.contains(*local)
-                    }
-                })
-            }
+            Some(items) => items.retain(|debuginfo| match debuginfo {
+                StmtDebugInfo::AssignRef(local, _) | StmtDebugInfo::InvalidAssign(local) => {
+                    locals.contains(*local)
+                }
+            }),
         }
     }
 }

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants