Skip to content
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

Replace internal hashtable with hashbrown RawTable #287

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

arthurprs
Copy link
Contributor

@arthurprs arthurprs commented Oct 23, 2023

Replace internal hashtable with hashbrown RawTable.

Benefits

  • Allows only hashing keys once
  • Allows a more efficient implementation of the Entry api. Which will always be a single hashtable operation.
    • Previously, building the entry would lookup the hashtable once, and other operations would do another lookup (e.g. OccupiedEntry::remove or VacantEntry::insert).
  • Allows dashmap raw api to be safely exposed even with the improvements above, as the shards are raw tables w/o hashers. This will avoid problems like Only hash keys once #259. crates.io use case (iterate the removed shards) will still be possible with rawtables.
  • Removes a lot of generic types for the hasher
  • Slightly simplifies some code paths as we don't have to fight lifetimes

The first two can be significant performance improvements in some circumstances.

Sadly, this is a breaking change for raw-api users so it'll require a major version bump.

Maybe the third time is the charm 😄

@arthurprs arthurprs marked this pull request as draft October 23, 2023 22:44
@arthurprs arthurprs marked this pull request as ready for review October 24, 2023 09:47
@conradludgate
Copy link
Contributor

A potentially nicer setup could be to use the new HashTable API instead of RawTable. I put together a WIP of that in this commit conradludgate@3023a51.

@arthurprs
Copy link
Contributor Author

arthurprs commented Jun 10, 2024

The downside with Hashtable is still has all the lifetimes and that doesn't play well with dashmap lock wrappers. Meaning we keep having to transmute lifetimes at every corner with change_lifetime_const, etc..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants