-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Try not to copy when allocating from iterators, take 3 #78107
Conversation
r? @oli-obk (rust_highfive has picked a reviewer for you, use r? to override) |
Oh, technically, this is a work in progress: I still need to put some time into naming things and clean up, but I don't want to do that before knowing if the change makes sense. |
@bors try @rust-timer queue |
Awaiting bors try build completion |
⌛ Trying commit 1690a82962ad3f9bd05bfbf04faccc18136756a9 with merge 7601a5e99583e48f583a8d083096b4882fb269ea... |
☀️ Try build successful - checks-actions, checks-azure |
Queued 7601a5e99583e48f583a8d083096b4882fb269ea with parent 9832374, future comparison URL. |
Finished benchmarking try commit (7601a5e99583e48f583a8d083096b4882fb269ea): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
Here's what (I think) I know:
I wonder if keeping the |
e0f26a4
to
a3d28db
Compare
So... you're suggesting we dispatch on whether something needs drop even earlier? Like have the check in the query system and then switch to |
I think using |
☔ The latest upstream changes (presumably #78569) made this pull request unmergeable. Please resolve the merge conflicts. Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:
|
Well I rebased this patch, but thinking about it more, these changes should have no or negligible effect so I'm closing it.
|
The problem I'm trying to solve here (and in previous PRs) is that,
TypedArena::alloc_from_iter
first creates a vector from the iterator's contents, then copies it into the arena. I'm trying to reuse the allocated vector instead of copying it's contents.Previous attempts have failed because of either unsoundness (#77945) or bad performance (#78067). This PR tried to address the issue by creating two, parallel arenas as part of a single
TypedArena
: one for "scalar" allocations, which includes slices of known size, and one for "vector" allocation, that store the vector objects created byalloc_from_iter
.While this increases the size ofThis change also wasn't able to achieve the desired performance, the increased size and complexity also caused slight regressions.TypedArena
, I hope this split results in better performance since allocating from an iter means moving theVec
object to an already known address, instead of having to compute it through a vector.Current state of the PR: I've reverted most of the above changes and only kept special casing the allocation where the type inside
TypedArena
does not need special considerations when dropping.