-
Notifications
You must be signed in to change notification settings - Fork 13.3k
binary_heap: Optimize Extend implementation. #108448
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
Conversation
This helper was written for retain() but will also be useful for extend().
Previously the bulk rebuild specialization was only available with Vec, and for general iterators Extend only provided pre-allocation through reserve(). By using a drop guard, we can safely bulk rebuild even if the iterator may panic. This allows benefiting from the bulk rebuild optimization without collecting iterator elements into a Vec beforehand, which would nullify any performance gains from bulk rebuild.
r? @m-ou-se (rustbot has picked a reviewer for you, use r? to override) |
Hey! It looks like you've submitted a new PR for the library teams! If this PR contains changes to any Examples of
|
Anyone around for review? |
r? libs |
r? libs |
Not familiar with binary heap internals. r? libs |
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (f13ccef): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. |
This PR makes the
Extend
implementation forBinaryHeap
no longer rely on specialization, so that it always use the bulk rebuild optimization that was previously only available for theVec
specialization.