Conversation
Contributor
|
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
m-ou-se
reviewed
Jan 21, 2021
Member
m-ou-se
left a comment
There was a problem hiding this comment.
Thanks for working on this!
I have a few comments:
Contributor
Author
|
@m-ou-se Fixed. Also updated the benchmark result. |
Member
|
@bors r+ |
Collaborator
|
📌 Commit 2a11c57 has been approved by |
Member
|
Thanks for working on this! |
Collaborator
Collaborator
|
☀️ Test successful - checks-actions |
niklasf
added a commit
to niklasf/arrayvec
that referenced
this pull request
Feb 19, 2021
bluss
pushed a commit
to niklasf/arrayvec
that referenced
this pull request
Mar 29, 2021
bluss
added a commit
to bluss/arrayvec
that referenced
this pull request
Mar 29, 2021
Mirror optimization of std::Vec::retain (rust-lang/rust#81126)
This was referenced Dec 10, 2021
This was referenced Dec 21, 2021
This was referenced Feb 24, 2022
This was referenced Mar 18, 2022
This was referenced May 13, 2022
This was referenced Mar 2, 2023
This was referenced Jun 14, 2023
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use
copy_non_overlappinginstead ofswapto reduce memory writes, like what we've done in #44355 andString::retain.#48065 already tried to do this optimization but it is reverted in #67300 due to bad codegen of
DrainFilter::drop.This PR re-implement the drop-then-move approach. I did a benchmark on small-no-drop, small-need-drop, large-no-drop elements with different predicate functions. It turns out that the new implementation is >20% faster in average for almost all cases. Only 2/24 cases are slower by 3% and 5%. See the link above for more detail.
I think regression in may-panic cases is due to drop-guard preventing some optimization. If it's permitted to leak elements when predicate function of element's
droppanic, the new implementation should be almost always faster than current one.I'm not sure if we should leak on panic, since there is indeed an issue (#52267) complains about it before.