-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Use usize
instead of u64
for hashes in HashMap
#36567
Comments
cc @rust-lang/compiler This might be relevant to |
I've made the PR #36595. Can anyone test see what effect it has on bootstrap on 32-bit? |
If we're hunting hashmap improvements, maybe one should even get ordermap into finished shape, and use rustc as a benchmark for it. |
We probably want to investigate switching the layout to HHHHHHKVKVKVKVKVKV as well, that will definitely improve the iteration and growing speed. There was an attempt here #21973 |
regarding the previous, I started experimenting in this branch arthurprs/hashmap2@e18a323 I'm a bit tired so I can't tell why insertions are quite slower, lookups are slight faster. |
-- removed bench |
That's very impressive @arthurps, any improvement like that must be welcome. Any downsides that you know of? The previous try stalled on code style / implementation details. The simple u64 → usize PR be merged long before, since it's a simple change. |
The lookup_100_000_multi_10p performance drop of course attracts some attention, is that something that's consistent between runs? Maybe there's a cache use change that can explain it. |
Oh right, one drawback that was mentioned is that |
@bluss yeah I'm not sure that's noise. Since Robin hood puts a good bound on the probing distance I think it may be a gain even if it wastes space in padding. I'll add a bench for that. |
I was a little skeptical so I made a round of benchmark improvements arthurprs/hashmap2@f8bd579. I tried to make sure value was not a
|
It would make sense for |
Discussed at libs triage the other day, our thoughts are on the PR. |
hashmap: Store hashes as usize internally We can't use more than usize's bits of a hash to select a bucket anyway, so we only need to store that part in the table. This should be an improvement for the size of the data structure on 32-bit platforms. Smaller data means better cache utilization and hopefully better performance. Fixes #36567
Just a note on the current implementation which stores the hash values per bucket as u64. We can't use more than
usize
's bits of a hash to select a bucket anyway, so we only need to store that part in the table. This would be an improvement on 32-bit platforms to make the hashmap's data structures smaller, hopefully improving cache utilization during insert and lookup.The text was updated successfully, but these errors were encountered: