clockworklabs / SpacetimeDB

Multiplayer at the speed of light
https://spacetimedb.com
Other
4.41k stars 110 forks source link

Consider switching to `foldhash` #1872

Open Centril opened 1 month ago

Centril commented 1 month ago

Hashbrown recently switched to foldhash instead of ahash and maybe we should as well.

Perhaps we should split our hashmap/sets into 3 categories:

  1. IntMap/Set -- identity hashing, when we don't need a hash at all, in the case of ids.
  2. FastMap/Set -- using foldhash-f when we don't care about Hash DoS, e.g., when the data comes from the DB state and not from user input.
  3. ResistMap/Set -- using foldhash-q or some other hasher like siphash.

This could gain us some performance wins.

Centril commented 1 month ago

Putting this in 1.0 because I don't know whether we rely on ahash anywhere, in the sense that changing to foldhash would break things, but we can move it out if we realize we don't.