-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Optimize BinaryHeap::extend from Vec #88282
Conversation
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
BinaryHeap doesn't have many benchmarks, maybe some could be added to show an improvement. |
I'm not sure if this is something for this PR, but I just noticed that the current specialization is on rust/library/alloc/src/collections/binary_heap.rs Lines 1550 to 1552 in 47ab5f7
For comparison this is how it's implemented for rust/library/alloc/src/vec/mod.rs Lines 2555 to 2557 in 47ab5f7
I believe we should copy |
Can you please inline the relevant pieces of discussion / why this is a win in general, etc. from the internals thread? This both avoids having to re-read that for context and ensures it's preserved for any future visitor (into git commit history). |
I edited the first post: as scottmcm mentioned:
is it enough? @Mark-Simulacrum |
Triage: setting this to waiting on review |
It looks like this PR is doing two separate things:
This first of these makes sense, seems fine, but the second I don't see a description of the goal in this PR. It also seems like these two changes are orthogonal and should belong in separate PRs? FWIW, saying "discussion is here" and pointing into the middle of an internals thread is not ideal; the PR description should ideally be self-contained or at least only point to documents or summary comments, not just discussion threads. This will speed up review and make the flow easier for everyone. @rustbot author (Please adjust the label with |
This comment has been minimized.
This comment has been minimized.
Ping from triage: @Neutron3529 - can you please address the merge conflicts and |
@rustbot ready It might be meanful that mark |
Please update the PR description to reflect the current state of this PR. Otherwise, this PR looks good to me, r=me with the description updated and commits squashed. |
The discussion is [here](https://internals.rust-lang.org/t/append-vec-to-binaryheap/15209/3)
SpecExtend
trait for Vec<T>
@rustbot ready |
SpecExtend
trait for Vec<T>
@bors r+ |
📌 Commit 2feee36 has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (ad44239): comparison url. Summary: This change led to moderate relevant mixed results 🤷 in compiler performance.
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 |
This improves the performance of extending
BinaryHeap
s from vectors directly. Future work may involve extending this optimization to other, similar, cases where the length of the added elements is well-known, but this is not yet done in this PR.