Fix a layout possible miscalculation in alloc::RawVec#83706
Fix a layout possible miscalculation in alloc::RawVec#83706bors merged 4 commits intorust-lang:masterfrom
alloc::RawVec#83706Conversation
|
(rust-highfive has picked a reviewer for you, use r? to override) |
I don't think so.
Makes sense.
I found at least one other place that used |
JohnTitor
left a comment
There was a problem hiding this comment.
This seems reasonable and I agree that we should also take a look at shrink:
rust/library/alloc/src/raw_vec.rs
Lines 470 to 479 in 451e98e
r=me once it's addressed.
|
Ping from triage:
Can you please address this |
117b686 to
fe942c2
Compare
|
Done, also fixed |
|
☔ The latest upstream changes (presumably #87408) made this pull request unmergeable. Please resolve the merge conflicts. |
fe942c2 to
e7f1c8e
Compare
|
Rebased |
|
Sorry for the delay! |
|
📌 Commit 03498aa has been approved by |
|
⌛ Testing commit 5376317 with merge ed9196e48a1c25c95588058b775e6c71cd47eb83... |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
|
💔 Test failed - checks-actions |
|
Uhm, another spurious failure came up... @bors retry |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (5bd1ec3): comparison url. Summary: This benchmark run shows 54 relevant regressions 😿 to instruction counts.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression |
|
@JohnTitor @a1phyr the perf regressions are somewhat small but still there are enough of them to warrant a check in on what's going on. I assume a small perf regression would be expected since we're now strictly doing more (e.g., checked multiplication), but is the magnitude of the regression here expected? |
simplify layout calculations in rawvec The use of `Layout::array` was introduced in rust-lang#83706 which lead to a [perf regression](rust-lang#83706 (comment)). This PR basically reverts that change since rust currently only supports stride == size types, but to be on the safe side it leaves a const-assert there to make sure this gets caught if those assumptions ever change.
simplify layout calculations in rawvec The use of `Layout::array` was introduced in #83706 which lead to a [perf regression](rust-lang/rust#83706 (comment)). This PR basically reverts that change since rust currently only supports stride == size types, but to be on the safe side it leaves a const-assert there to make sure this gets caught if those assumptions ever change.
simplify layout calculations in rawvec The use of `Layout::array` was introduced in #83706 which lead to a [perf regression](rust-lang/rust#83706 (comment)). This PR basically reverts that change since rust currently only supports stride == size types, but to be on the safe side it leaves a const-assert there to make sure this gets caught if those assumptions ever change.
A layout miscalculation could happen in
RawVecwhen used with a type whose size isn't a multiple of its alignment. I don't know if such type can exist in Rust, but the Layout API provides ways to manipulate such types. Anyway, it is better to calculate memory size in a consistent way.