Skip to content

Use real ThinVec in StmtDebugInfos - #159975

Draft
panstromek wants to merge 5 commits into
rust-lang:mainfrom
panstromek:simplify-debuginfos
Draft

Use real ThinVec in StmtDebugInfos#159975
panstromek wants to merge 5 commits into
rust-lang:mainfrom
panstromek:simplify-debuginfos

Conversation

@panstromek

Copy link
Copy Markdown
Contributor

This is now possible, because thin vec has may_dangle Drop impl. Depends on #159974

…get may_dangle drop impl

This also enables TrustedLen impl, which is behind unstable flag, too, so this might have soundness or perf implications
@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) 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 26, 2026
@panstromek

panstromek commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

(mostly empty) ThinVec has slightly different performance profile compared to our poor man's thin-vec (Option<Box<Vec>>>) - empty thin vec uses a static sentinel value, whic means that reading len is branchless. There's one less branch on empty check now (previously, we needed branch on option, then branch on len). On the other hand, reading len reads some random hot 0 in static memory, which could be costlier if it's cold, compared to reading local None value.

I also changed some of the inline/outline combos in other methods, I kept it where it felt potentially useful, but I might have perturbed the performance profile because inlining is finicky.

Long story short, I want to measure this to see whether these things make some noticable difference.

@bors try @rust-timer queue

Of course, non-empty variant has one less allocation, which is good, but this is extremely rare case, so I don't worry about perf changes there.

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 26, 2026
rust-bors Bot pushed a commit that referenced this pull request Jul 26, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 168b7f9 (168b7f942221b2ae2c1aac25e9a4ae3908bf981a)
Base parent: 9451e06 (9451e069c34e1d7db23a155dcf9c25d1bc127055)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (168b7f9): comparison URL.

Overall result: ❌ regressions - 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 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.2% [0.2%, 0.2%] 3
Regressions ❌
(secondary)
0.5% [0.2%, 2.6%] 32
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.2% [-0.2%, -0.2%] 2
All ❌✅ (primary) 0.2% [0.2%, 0.2%] 3

Max RSS (memory usage)

Results (primary -0.9%, secondary -4.1%)

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

mean range count
Regressions ❌
(primary)
1.4% [1.4%, 1.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.2% [-3.2%, -3.2%] 1
Improvements ✅
(secondary)
-4.1% [-5.7%, -2.5%] 2
All ❌✅ (primary) -0.9% [-3.2%, 1.4%] 2

Cycles

Results (secondary 4.1%)

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)
4.1% [3.2%, 5.0%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.1%, -0.0%] 2
Improvements ✅
(secondary)
-0.0% [-0.1%, -0.0%] 2
All ❌✅ (primary) -0.0% [-0.1%, -0.0%] 2

Bootstrap: 489.176s -> 489.973s (0.16%)
Artifact size: 387.73 MiB -> 387.67 MiB (-0.02%)

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

Copy link
Copy Markdown
Contributor Author

wow, I expected some perturbation but this is surprisingly negative. Let me check the update by itself.

@panstromek

Copy link
Copy Markdown
Contributor Author

Let's backtrack a bit and keep the option in there for now

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

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Jul 27, 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:1080:
         if debuginfos.is_empty() {
             return;
         };
-        outline(move || {
-            self.0.get_or_insert_default().append(debuginfos.0.as_mut().unwrap())
-        });
+        outline(move || self.0.get_or_insert_default().append(debuginfos.0.as_mut().unwrap()));
     }
     #[inline]
     pub fn extend(&mut self, debuginfos: &Self) {
fmt: checked 7055 files
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`

@panstromek

panstromek commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Actually, the results here are very similar to results in #159928 (comment), so this might actually be just the thin-vec update. Let's wait for that perf run to confirm this.

@rust-bors

rust-bors Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: d58d011 (d58d0115ee77a3f917991930660a90216aa41fbd)
Base parent: dfbea5b (dfbea5bc945a9d7ff017d3d4bfbd1af9295fe5b8)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (d58d011): comparison URL.

Overall result: ❌ regressions - 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 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.6% [0.3%, 2.6%] 18
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary -0.8%)

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.3% [2.0%, 2.6%] 2
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.0% [-5.7%, -2.3%] 2
All ❌✅ (primary) - - 0

Cycles

Results (secondary 5.6%)

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

Binary size

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

Bootstrap: 486.74s -> 496.176s (1.94%)
Artifact size: 387.74 MiB -> 387.80 MiB (0.02%)

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

panstromek commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

ok, the new-solver changes are due to ThinVec update, but apart from that, the second perf run looks better, so let's keep the Option there. We'll figure the new-solver regressions in #159974

@rustbot blocked

@rustbot rustbot added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 27, 2026
@rust-bors

rust-bors Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #160021) made this pull request unmergeable. Please resolve the merge conflicts by rebasing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-attributes Area: Attributes (`#[…]`, `#![…]`) perf-regression Performance regression. S-blocked Status: Blocked on something else such as an RFC or other implementation work. 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