-
Notifications
You must be signed in to change notification settings - Fork 7
Sub-optimal performance on remove during resize #1
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
Comments
Erasing an element doesn't actually invalidate a |
Ah, I think maybe some context is needed here. The iterator griddle keeps is an iterator over the "old" table of elements that have not yet been moved. We keep that iterator around even while other operations are performed (like removals) so that the next insert can immediately get the next item to move without having to scan for non-empty buckets. There are no elements left "before" the iterator, as they have all been moved. The issue here is that the user calls Lines 783 to 787 in 91b0f5b
Triggered this assertion: |
I think a "general" refresh is probably too tricky to add (e.g., you wouldn't know how to change |
This fixes both #1 and #2 by taking advantage of rust-lang/hashbrown#167. It won't work until that PR is merged, and also requires an implementation of `Clone` for `RawIntoIter`.
…odecov-action-3 Bump codecov/codecov-action from 2 to 3
When a remove happens during the resize period, we need to restart the
RawIter
we have over the old table to track which elements have yet to be removed. This restart happens here:griddle/src/lib.rs
Lines 865 to 871 in b2a063c
Unfortunately, when the iterator is restarted this way, it has to walk all the empty buckets of elements we have already moved the next time we try to move a key. When the old map is large, this can take a significant amount of time.
It would be better if we could "refresh" the iterator instead. This should be possible, since we know the old table has neither shrunk nor grown. I probably requires some changes internally in
hashbrown
. I pinged thehashbrown
author about it in rust-lang/hashbrown#166 (comment).The text was updated successfully, but these errors were encountered: