]> git.hungrycats.org Git - bees/commitdiff
xxhash: add xxhash3 config option
authorZygo Blaxell <bees@furryterror.org>
Fri, 1 May 2026 16:54:22 +0000 (12:54 -0400)
committerZygo Blaxell <bees@furryterror.org>
Sat, 5 Sep 2026 04:03:57 +0000 (00:03 -0400)
XXH3_64bits is now stable in xxHash 0.8.x and is ~2x faster than
XXH64 on SSE2 hardware.  Expose it as function = xxhash3 in
[hash.NAME] config sections.

Assisted-by: Claude-Code:claude-sonnet-4-6
Signed-off-by: Zygo Blaxell <bees@furryterror.org>
src/bees-config-v1.cc
src/bees-context.cc
src/bees-hash-domain.cc
src/bees-hash-domain.h

index 6bb776b0e6b7e27a30e0708ba5fa183a31b26ed6..c78dd1ebd743276bd8956c2d949c6dddda274be2 100644 (file)
@@ -444,7 +444,7 @@ static const char bees_config_v1[] = R"--v1-config--(
 #
 # Each concrete [hash.NAME] section must name its own hash function.
 # The function is the defining identity of a hash domain and has no
-# default in [hash.*].  Supported values: crc64, cityhash, xxhash.
+# default in [hash.*].  Supported values: crc64, cityhash, xxhash, xxhash3.
 # Other values (btrfs, crc32c, sha256, blake2) are reserved for
 # future implementation.
 #
index 0c0b68578ae33aeb77cecd95bac77266b7d1d744..26c0eb108357bf9f1777dd68016fc41b5f9bcbf2 100644 (file)
@@ -1257,6 +1257,7 @@ BeesContext::start()
                                case BeesHashFunction::crc64:    return "crc64";
                                case BeesHashFunction::cityhash: return "cityhash";
                                case BeesHashFunction::xxhash:   return "xxhash";
+                               case BeesHashFunction::xxhash3:  return "xxhash3";
                        }
                        return "unknown";
                }();
index 85614a705a32dea909bb53a612373a2e5790db89..fc076f68619cd198256d1720315f0b3279d0e503 100644 (file)
@@ -27,6 +27,9 @@ BeesHashDomain::hash(const uint8_t *ptr, size_t len) const
                case BeesHashFunction::xxhash:
                        h = XXH64(ptr, len, 0);
                        break;
+               case BeesHashFunction::xxhash3:
+                       h = XXH3_64bits(ptr, len);
+                       break;
        }
        // seed == 0 (enforced by bees_parse_hash_domains), so
        // finalization is a no-op.  The branch is present so the
@@ -52,7 +55,8 @@ parse_hash_function(const string &name, const string &val)
        if (val == "crc64")    return BeesHashFunction::crc64;
        if (val == "cityhash") return BeesHashFunction::cityhash;
        if (val == "xxhash")   return BeesHashFunction::xxhash;
-       // Give a clear message for functions reserved for scan_next_extent.
+       if (val == "xxhash3")  return BeesHashFunction::xxhash3;
+       // Give a clear message for functions reserved for future implementation.
        if (val == "btrfs" || val == "crc32c" || val == "sha256" || val == "blake2") {
                throw runtime_error(
                        "[hash." + name + "] function = '" + val +
@@ -60,8 +64,8 @@ parse_hash_function(const string &name, const string &val)
                );
        }
        throw runtime_error(
-               "[hash." + name + "] function = " + val +
-               " is unknown; supported values: crc64, cityhash, xxhash"
+               "[hash." + name + "] function = '" + val +
+               "' is unknown; supported values: crc64, cityhash, xxhash, xxhash3"
        );
 }
 
index aaf6ec81ffdda3cffe044199f6dc41fa57976e6d..24896b78cdd954941a0d0b07684c0d35844ab43b 100644 (file)
@@ -18,6 +18,7 @@ enum class BeesHashFunction {
        crc64,    ///< CRC-64 (current default; backward-compatible with existing beeshash.dat)
        cityhash, ///< CityHash64
        xxhash,   ///< XXHash64
+       xxhash3,  ///< XXHash3 64-bit (faster than xxhash on modern hardware; incompatible with xxhash)
 };
 
 /// Immutable runtime object for one configured [hash.NAME] section.
@@ -48,7 +49,7 @@ struct BeesHashDomain {
 /// - size must equal 4096
 /// - seed must be 0
 /// - insert must be true
-/// - function must be one of: crc64, cityhash, xxhash
+/// - function must be one of: crc64, cityhash, xxhash, xxhash3
 /// - no duplicate section names
 /// - at least one insert domain must exist
 ///