Skip to content

Just pass Layout directly to box_new_uninit#152737

Open
scottmcm wants to merge 2 commits intorust-lang:mainfrom
scottmcm:box_new_uninit_layout
Open

Just pass Layout directly to box_new_uninit#152737
scottmcm wants to merge 2 commits intorust-lang:mainfrom
scottmcm:box_new_uninit_layout

Conversation

@scottmcm
Copy link
Member

@scottmcm scottmcm commented Feb 17, 2026

We have a constant for it already (used in RawVec for basically the same polymorphization) so let's use it.

This is a simple follow-up to #148190 from one of the comments.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 17, 2026
@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 17, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 17, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
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: libs
  • libs expanded to 7 candidates
  • Random selection from Mark-Simulacrum, joboet

@scottmcm
Copy link
Member Author

Since we saw this code is perf-sensitive, to make sure it doesn't blow up...
@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 Feb 17, 2026
Just pass `Layout` directly to `box_new_uninit`
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 17, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 17, 2026

☀️ Try build successful (CI)
Build commit: 8dd6c97 (8dd6c970aade6a83f0d68d1c80913bde8aa79b32, parent: 3c9faa0d037b9eecda4a440cc482ff7f960fb8a5)

@rust-timer

This comment has been minimized.

@scottmcm scottmcm force-pushed the box_new_uninit_layout branch from f6af841 to d413781 Compare February 17, 2026 03:27
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8dd6c97): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@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.7% [0.4%, 1.0%] 3
Regressions ❌
(secondary)
0.6% [0.6%, 0.6%] 2
Improvements ✅
(primary)
-0.3% [-0.4%, -0.2%] 2
Improvements ✅
(secondary)
-1.0% [-3.2%, -0.4%] 8
All ❌✅ (primary) 0.3% [-0.4%, 1.0%] 5

Max RSS (memory usage)

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

Cycles

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

Binary size

Results (primary -0.2%, secondary -2.0%)

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

mean range count
Regressions ❌
(primary)
0.3% [0.3%, 0.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.5%, -0.0%] 19
Improvements ✅
(secondary)
-2.0% [-4.2%, -0.7%] 15
All ❌✅ (primary) -0.2% [-0.5%, 0.3%] 20

Bootstrap: 480.798s -> 483.051s (0.47%)
Artifact size: 395.81 MiB -> 395.83 MiB (0.00%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 17, 2026
@rust-log-analyzer

This comment has been minimized.

@scottmcm scottmcm force-pushed the box_new_uninit_layout branch 2 times, most recently from 035fa58 to 9ed30a0 Compare February 17, 2026 08:31
@scottmcm
Copy link
Member 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 Feb 17, 2026
Just pass `Layout` directly to `box_new_uninit`
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 17, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 17, 2026

☀️ Try build successful (CI)
Build commit: b517e4f (b517e4fd131ad3e507891d12ba6980349893b354, parent: d1a11b670b617f1370f7b1cdf86e225a4e070f15)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b517e4f): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @rustbot label: +perf-regression-triaged. If not, please fix the regressions and do another perf run. If its results are neutral or positive, the label will be automatically removed.

@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.8% [0.8%, 0.8%] 1
Regressions ❌
(secondary)
0.8% [0.6%, 0.9%] 5
Improvements ✅
(primary)
-0.7% [-1.2%, -0.3%] 13
Improvements ✅
(secondary)
-1.8% [-4.1%, -0.8%] 11
All ❌✅ (primary) -0.6% [-1.2%, 0.8%] 14

Max RSS (memory usage)

Results (primary 1.3%, secondary 2.1%)

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

mean range count
Regressions ❌
(primary)
4.1% [2.8%, 8.5%] 5
Regressions ❌
(secondary)
3.4% [1.3%, 5.7%] 13
Improvements ✅
(primary)
-3.4% [-3.5%, -3.2%] 3
Improvements ✅
(secondary)
-3.8% [-4.1%, -3.4%] 3
All ❌✅ (primary) 1.3% [-3.5%, 8.5%] 8

Cycles

Results (primary 2.3%, secondary -3.5%)

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

mean range count
Regressions ❌
(primary)
2.3% [2.3%, 2.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.5% [-3.6%, -3.2%] 3
All ❌✅ (primary) 2.3% [2.3%, 2.3%] 1

Binary size

Results (primary -0.6%, secondary -2.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)
- - 0
Improvements ✅
(primary)
-0.6% [-1.2%, -0.0%] 21
Improvements ✅
(secondary)
-2.1% [-3.6%, -0.1%] 18
All ❌✅ (primary) -0.6% [-1.2%, -0.0%] 21

Bootstrap: 483.207s -> 482.56s (-0.13%)
Artifact size: 397.79 MiB -> 397.80 MiB (0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 17, 2026
Copy link
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

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

Nice :)

r=me with safety comment fixed, unless you have further plans.

View changes since this review

@@ -319,12 +315,7 @@ impl<T> Box<T> {
// SAFETY:
// - The size and align of a valid type `T` are always valid for `Layout`.
Copy link
Member

Choose a reason for hiding this comment

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

This first point seems outdated now.

We have a constant for it already (used in `RawVec` for basically the same polymorphization) so let's use it.

Conveniently, it can even be safe that way!
@scottmcm scottmcm force-pushed the box_new_uninit_layout branch from 9ed30a0 to 4b03b97 Compare February 17, 2026 17:10
@scottmcm
Copy link
Member Author

@bors r=RalfJung

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 17, 2026

📌 Commit 4b03b97 has been approved by RalfJung

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 Feb 17, 2026
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-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. T-libs Relevant to the library 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