-
Notifications
You must be signed in to change notification settings - Fork 13.3k
RawVec: don't recompute capacity after allocating. #92220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RawVec: don't recompute capacity after allocating. #92220
Conversation
Currently it sets the capacity to `ptr.len() / mem::size_of::<T>()` after any buffer allocation/reallocation. This would be useful if allocators ever returned a `NonNull<[u8]>` with a size larger than requested. But this never happens, so it's not useful. Removing this slightly reduces the size of generated LLVM IR, and slightly speeds up the hot path of `RawVec` growth.
@bors try @rust-timer queue I expect this will be tiny wins at best, it's more about the code cleanliness. |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 8217138 with merge bb1b81b9cddfac8bb2c85068496511df09d999bc... |
☀️ Try build successful - checks-actions |
Queued bb1b81b9cddfac8bb2c85068496511df09d999bc with parent e983092, future comparison URL. |
Finished benchmarking commit (bb1b81b9cddfac8bb2c85068496511df09d999bc): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR led to changes in compiler perf. @bors rollup=never |
If you deselect "Filter out very small changes" in the perf results you see lots of tiny wins (< 0.3%), as expected. |
@bors r+ |
📌 Commit 8217138 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (e6f1f04): comparison url. Summary: This benchmark run did not return any relevant changes. If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. @rustbot label: -perf-regression |
Currently it sets the capacity to
ptr.len() / mem::size_of::<T>()
after any buffer allocation/reallocation. This would be useful if
allocators ever returned a
NonNull<[u8]>
with a size larger thanrequested. But this never happens, so it's not useful.
Removing this slightly reduces the size of generated LLVM IR, and
slightly speeds up the hot path of
RawVec
growth.r? @ghost