Skip to content

util/hash_table: replace _mesa_hash_data's fnv1a hash function with xxhash

Anthony Pesch requested to merge apesch/mesa:xxhash into master

This is a MR for the issue discussed in #2153 (closed).

The original patch in the issue only swapped in xxhash for the v3d driver's hash table usage, but this MR (as per the bug discussion) makes it the default for _mesa_hash_data itself.

I broke this into a few commits as I wasn't sure how much change was wanted:

  • First commit adds the xxhash dependency.
  • (optional) Second commit moves fnv1a routine into its own header. Now that fnv1a isn't the only hash function used by hash_table.c, I tossed it into its own header like xxhash.
  • Third commit finally replaces the fnv1a usage in _mesa_hash_data with xxhash.
  • (optional) Fourth commit adds int / unsigned int / uint32 hash functions which use an inlined version of XXH32 that's optimized for the key size.
  • (optional) Fifth commit replaces uses of _mesa_hash_data for integers with the new optimized routines.

The last two commits came because I was concerned about regressing performance for users now hashing small keys with xxhash (which is known to be slightly slower in this case). After inlining XXH32 with the constant key size I believe the difference should be marginal outside of a benchmark.

Merge request reports