-
Notifications
You must be signed in to change notification settings - Fork 294
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
Add RawTable::vacuum
to clean up DELETED entries
#255
base: master
Are you sure you want to change the base?
Conversation
This cleans the table to ensure the maximum usable capacity in its current allocation, rehashing items that need to move around previously-deleted entries.
This was inspired by indexmap-rs/indexmap#183, and the name by a database |
I have doubts about how useful this will be in practice. In almost all cases |
I'm trying to provide an option for the concern in indexmap-rs/indexmap#183 (comment):
In that scenario, I suppose they might be working more than half full, where |
You could just reserve 2x the needed capacity, which ensures that Or just don't do anything: in the worst case you get a single reallocation, after which the |
To provide a bit more context, the memory constrained environment I'm working in is an audio library. Generally people working with audio don't want to allocate memory on the audio thread, because if the operating system takes a long time to allocate memory, it could result in audio stuttering, which is very unpleasant. So once I create a hash map, I never want to allocate memory for it again. It may just be that I need a more specialized data structure. |
As I've said before, hashbrown will automatically clean up deleted entries when it runs out of capacity so it won't call out to the allocator to grow the table unless you actually need it. |
☔ The latest upstream changes (presumably #458) made this pull request unmergeable. Please resolve the merge conflicts. |
This cleans the table to ensure the maximum usable capacity in its
current allocation, rehashing items that need to move around
previously-deleted entries.