Skip to content

RawVec: don't recompute capacity after allocating. - #92220

Merged
bors merged 1 commit into
rust-lang:masterfrom
nnethercote:RawVec-dont-recompute-capacity
Dec 24, 2021
Merged

bors merged 1 commit into
rust-lang:masterfrom
nnethercote:RawVec-dont-recompute-capacity

Conversation

@nnethercote

Copy link
Copy Markdown
Contributor

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.

r? @ghost

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

Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

I expect this will be tiny wins at best, it's more about the code cleanliness.

@rust-timer

Copy link
Copy Markdown
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 23, 2021
@bors

bors commented Dec 23, 2021

Copy link
Copy Markdown
Collaborator

⌛ Trying commit 8217138 with merge bb1b81b9cddfac8bb2c85068496511df09d999bc...

@bors

bors commented Dec 23, 2021

Copy link
Copy Markdown
Collaborator

☀️ Try build successful - checks-actions
Build commit: bb1b81b9cddfac8bb2c85068496511df09d999bc (bb1b81b9cddfac8bb2c85068496511df09d999bc)

@rust-timer

Copy link
Copy Markdown
Collaborator

Queued bb1b81b9cddfac8bb2c85068496511df09d999bc with parent e983092, future comparison URL.

@rust-timer

Copy link
Copy Markdown
Collaborator

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
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Dec 23, 2021
@nnethercote

Copy link
Copy Markdown
Contributor Author

If you deselect "Filter out very small changes" in the perf results you see lots of tiny wins (< 0.3%), as expected.

@joshtriplett

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Dec 24, 2021

Copy link
Copy Markdown
Collaborator

📌 Commit 8217138 has been approved by joshtriplett

@bors bors 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 Dec 24, 2021
@bors

bors commented Dec 24, 2021

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 8217138 with merge e6f1f04...

@bors

bors commented Dec 24, 2021

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: joshtriplett
Pushing e6f1f04 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Dec 24, 2021
@bors
bors merged commit e6f1f04 into rust-lang:master Dec 24, 2021
@rustbot rustbot added this to the 1.59.0 milestone Dec 24, 2021
@nnethercote
nnethercote deleted the RawVec-dont-recompute-capacity branch December 24, 2021 06:23
@rust-timer

Copy link
Copy Markdown
Collaborator

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

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

Labels

merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants