-
Notifications
You must be signed in to change notification settings - Fork 84
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
Use Vec::retain instead of Vec::remove #83
Merged
Merged
Conversation
This file contains 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
Kerollmops
force-pushed
the
use-vec-retain-instead-of-remove
branch
from
January 19, 2021 15:19
926dc1f
to
50e9cf7
Compare
bors try |
tryBuild failed: |
bors try |
bors try |
tryAlready running a review |
bors try |
tryAlready running a review |
Kerollmops
force-pushed
the
use-vec-retain-instead-of-remove
branch
from
January 19, 2021 18:23
64897f0
to
7be13bd
Compare
bors try |
tryAlready running a review |
tryBuild failed:
|
bors try |
tryBuild succeeded: |
bors r+ |
Build succeeded: |
bors bot
added a commit
that referenced
this pull request
Jan 23, 2021
85: Replace Vec remove by a retain_mut function in Container operations r=Kerollmops a=Kerollmops We introduce a `retain_mut` function that allows us to mutate the iterated element. There already were [a discussion about this `Vec::retain` parameter restriction](rust-lang/rust#25477). Using the `retain` algorithm is much better when multiple stores must be removed in one batch, same as in #83. Co-authored-by: Clément Renault <[email protected]>
not-jan
pushed a commit
to not-jan/roaring-rs
that referenced
this pull request
Aug 31, 2022
83: Use Vec::retain instead of Vec::remove r=Kerollmops a=Kerollmops There are many places where we use [the `Vec::remove` method](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.remove). It can bring a lot of performances issues as every time this function is called, the right part of the Vec (after the removed element) is shifted to the left by one, when a lot of element must be removed, we should always use [`Vec::retain`](https://doc.rust-lang.org/std/vec/struct.Vec.html#method.retain) which is more optimized for this in the sense that it will avoid calling a lot the copy function for when multiple elements must be removed at the same time. I found that doing this change in the `Store::intersect_with` method for the Array-Array operation gave me much better performances (7m intersected with 3m and intersected with 4m again), moving from 240ms to 55ms. I am sure that we can optimize the current implementation more. - [x] Stores intersections. - [x] Stores differences. - [ ] Stores symmetric differences. Co-authored-by: Clément Renault <[email protected]> Co-authored-by: Kerollmops <[email protected]>
not-jan
pushed a commit
to not-jan/roaring-rs
that referenced
this pull request
Aug 31, 2022
85: Replace Vec remove by a retain_mut function in Container operations r=Kerollmops a=Kerollmops We introduce a `retain_mut` function that allows us to mutate the iterated element. There already were [a discussion about this `Vec::retain` parameter restriction](rust-lang/rust#25477). Using the `retain` algorithm is much better when multiple stores must be removed in one batch, same as in RoaringBitmap#83. Co-authored-by: Clément Renault <[email protected]>
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.
There are many places where we use the
Vec::remove
method. It can bring a lot of performances issues as every time this function is called, the right part of the Vec (after the removed element) is shifted to the left by one, when a lot of element must be removed, we should always useVec::retain
which is more optimized for this in the sense that it will avoid calling a lot the copy function for when multiple elements must be removed at the same time.I found that doing this change in the
Store::intersect_with
method for the Array-Array operation gave me much better performances (7m intersected with 3m and intersected with 4m again), moving from 240ms to 55ms. I am sure that we can optimize the current implementation more.