Avoid sorting in hash map stable hashing by Kobzol · Pull Request #91837 · rust-...
source link: https://github.com/rust-lang/rust/pull/91837
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Suggested by @the8472 here. I hope that I understood it right, I replaced the sort with modular multiplication, which should be commutative.
Can I ask for a perf. run? However, locally it didn't help at all. Creating the StableHasher
all over again is probably slowing it down quite a lot. And using FxHasher
is not straightforward, because the keys and values only implement HashStable
(and probably they shouldn't be just hashed via Hash
anyway for it to actually be stable).
Maybe the StableHash
interface could be changed somehow to better suppor these scenarios where the hasher is short-lived. Or the StableHasher
implementation could have variants with e.g. a shorter buffer for these scenarios.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK