Skip to main content

KevyHash

Trait KevyHash 

Source
pub trait KevyHash {
    // Required method
    fn kevy_hash(&self) -> u64;
}
Expand description

Single-call hashing for kevy’s per-command hot path.

std::hash::Hasher is a state-machine API — every hash is Hasher::default()write_*finish, with BuildHasher indirection on top. For kevy-map’s open-addressing table the keyspace is a small handful of well-known leaf types ([u8], u32, u64, i32); we get a faster, inline- friendly hash by exposing one method on each that produces the final mixed 64-bit value in one go.

All impls must agree with feeding the value through FxHasher then calling finish — this lets us cut the trait dispatch without changing the hash function. kevy-map consumes both the full hash (for bucket index) and its top 7 bits (for the metadata byte).

Required Methods§

Source

fn kevy_hash(&self) -> u64

Compute the final mixed 64-bit hash of self in one call.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl KevyHash for Vec<u8>

Source§

fn kevy_hash(&self) -> u64

Source§

impl KevyHash for [u8]

Source§

fn kevy_hash(&self) -> u64

Byte-slice hash. Uses the two-stream pipelined path internally for ILP on the bench’s 8-64 byte keyspace, closing the prior 1 ns gap vs rustc-hash 2.x’s hash_bytes. The final fmix64 retains the anti-clustering guarantee that the no_catastrophic_clustering_on_low_entropy_keys test enforces.

Note: the result diverges from the legacy FxHasher absorb path — callers using FxHashMap<Vec<u8>, _> route through std’s Hash::hash → Hasher::write → finish (the legacy single-stream path), which intentionally stays put for cross-instance hash stability with anything that depended on the v0.polish bit pattern. The KevyHash for [u8] impl is for one-call hot paths like kevy-map::find_by_borrow, which is the only one we measure.

Source§

impl KevyHash for i32

Source§

fn kevy_hash(&self) -> u64

Source§

impl KevyHash for u32

Source§

fn kevy_hash(&self) -> u64

Source§

impl KevyHash for u64

Source§

fn kevy_hash(&self) -> u64

Source§

impl KevyHash for usize

Source§

fn kevy_hash(&self) -> u64

Implementors§