Reduce size overhead of adaptative hashmap#40237
Conversation
|
r? @BurntSushi (rust_highfive has picked a reviewer for you, use r? to override) |
src/libstd/collections/hash/table.rs
Outdated
There was a problem hiding this comment.
1 is the smallest alignment possible, so this assertion is always triggered, no?
There was a problem hiding this comment.
I was under the impression that hashes in raw table is always aligned to at least four. I'll double check.
There was a problem hiding this comment.
So, a few comments here.
While I don’t think that happens in practice, it is certainly possible for HashUint get an alignment of 1 in theory. For example a custom data-layout could be used to achieve that. This is one minor portability concern.
I’m somewhat doubting the need to have this as a generic pointer, rather than just a TaggedHashUintPtr type. This is so unusual a thing to do, that having a generic version is unlikely to ever have any benefit.
There was a problem hiding this comment.
Good point, I'll get rid of the generic.
|
I screwed the diff, will fix shortly. |
|
@arthurprs I remember you having some nice benchmarks for previous PR. Could you rerun those and make a comparison between having separate bool, embedding bool into tagged pointer and the state before adaptive hashing was implemented? |
3010727 to
347180f
Compare
|
I did some benchmarks and discovered some weird inline failures There's things like really... same for the small functions of the tagged ptr. I added some inline annotations and it was enough to bring the performance diff down to noise. |
Exposes a boolean flag in RawTable and use it instead of a bool field in HashMap. Fixes: rust-lang#40042
These happened because All in all implementation of this looks very good to me, but since I’m not a T-libs person, I cannot take the liberty to r+ this. |
|
@bors: r+ Thanks @arthurprs! |
|
📌 Commit 3273003 has been approved by |
Reduce size overhead of adaptative hashmap Exposes a boolean flag in RawTable and use it instead of a bool field in HashMap. Taking a bit from capacity or length would make overflow handling tricky. Fixes: rust-lang#40042
Exposes a boolean flag in RawTable and use it instead of a bool field in HashMap.
Taking a bit from capacity or length would make overflow handling tricky.
Fixes: #40042