Crate museair

Source
Expand description

§MuseAir

MuseAir is a portable hashing algorithm that heavily optimized for performance and quality, incorporating structures never before implemented. Complete algorithm analysis is available in the repository.

  • Even faster, outperforming previous fastest wyhash and rapidhash.

  • Improved quality, not vulnerable to blinding multiplication like wyhash or rapidhash, making it ideal for persistent file formats or communication protocols (though note the algorithm is not yet stable).

  • Platform independent, no dependencies on specialized instruction sets like cryptography or vectorization, runs optimally on most 64-bit architectures.

  • Compile-time hashing, as the implementation is fully const.

  • No-std compatible, zero unsafe code and zero dependencies.

  • Non-cryptographic, not intended for security-critical applications.

§Usage

let seed: u64 = 1123;

let v1: u64 = museair::hash("K--Aethiax".as_bytes(), seed);
let v2: u64 = {
    let mut hasher = museair::Hasher::new(seed);
    hasher.write("K--Ae".as_bytes());
    hasher.write("thiax".as_bytes());
    hasher.finish()
};

let v3: u128 = museair::hash_128("K--Aethiax".as_bytes(), seed);
let v4: u128 = {
    let mut hasher = museair::Hasher::new(seed);
    hasher.write("K--Ae".as_bytes());
    hasher.write("thiax".as_bytes());
    hasher.finish_128()
};

assert_eq!(v1, v2);
assert_eq!(v3, v4);
§Use with hashmap

This crate provides helper types that require enabling the std feature.

use museair::{HashMap, FixedState};

let mut map = HashMap::default();
map.insert("hello", "world");

let mut map = HashMap::with_hasher(FixedState::new(42));
map.insert("hello", "world");

§Feature flags

  • std (enabled by default) - Enables HashMap and HashSet helper types.

§Benchmarks

Benchmarks conducted on AMD Ryzen 7 5700G desktop.

§Hashing bulk datas

Bench bulk datas (using SMHasher3) Bench bulk datas (using Criterion.rs)

§Hashing small keys

Bench small keys (using SMHasher3)

For common 1-32 byte keys, MuseAir has a significant speed advantage (avg. 13.0 cycles/hash), even outperforming fxhash.

§Quality

All MuseAir variants have passed the complete SMHasher3 extended test suite (with --extra flag). As the de facto standard for non-cryptographic hashing quality, passing these tests confirms production readiness. See full results in the repository.

§Versioning

The current MSRV (Minimum Supported Rust Version) is 1.83.0. MSRV changes are considered breaking changes.

Modules§

bfast
The BFast variant of the MuseAir hashing algorithm.
impls
Implementation details of the MuseAir hashing algorithm.

Functions§

hash
Computes the 64-bit MuseAir hash for a byte slice. (standard variant)
hash_128
Computes the 128-bit MuseAir hash for a byte slice. (standard variant)

Type Aliases§

FixedState
A BuildHasher for the MuseAir incremental Hasher that always has the same fixed seed. (standard variant)
HashMapstd
A HashMap type that uses the MuseAir incremental Hasher. (standard variant)
HashSetstd
A HashSet type that uses the MuseAir incremental Hasher. (standard variant)
Hasher
An incremental Hasher instance that uses the MuseAir hashing algorithm. (standard variant)