MCHPR / MCHPRS

A multithreaded Minecraft server built for redstone.
MIT License
1.55k stars 68 forks source link

Replace default std hasher with rustc-hash #121

Closed Paul1365972 closed 11 months ago

Paul1365972 commented 11 months ago

The default std HashMap/HashSet uses a cryptograpthic hash function (SipHash), this is definitely overkill. Since we don't need to protect against Hash DoS we can just use the same hash function that the rust compiler internally uses. The lower hash quality, and therefore resulting higher collision count, are offset by the drastically faster hashing algorithm.

I would have liked to replace all instances of HashMap, but that would mean also changing the nbt crate. Maybe a possible future enhancement. Anyways, the most important use cases are covered by this commit.

StackDoubleFlow commented 11 months ago

Thanks!