Skip to main content

Module hash

Module hash 

Source
Expand description

Small, stable hash helpers shared across ff-sdk + ff-scheduler + ff-engine. Not security-sensitive — these are for cardinality reduction (log digests) and deterministic-but-spread iteration (partition-scan start offsets). A single source of truth avoids drift if the algorithm changes.

Both helpers implement FNV-1a 64-bit with the standard offset basis and prime (see http://www.isthe.com/chongo/tech/comp/fnv/). FNV-1a is fast (byte-at-a-time), has good avalanche on short keys, and produces stable output across platforms — important because these digests leak into logs that operators grep against.

Functions§

fnv1a_u64
FNV-1a 64-bit over raw bytes. Kept public for callers that need the full hash width (rare — most sites want the folded/reduced helpers above).
fnv1a_u16_mod
FNV-1a of the input, reduced modulo modulus. Returns 0 when modulus == 0. Used for deterministic-but-spread scan-start offsets (partition jitter). Callers pass a non-zero modulus.
fnv1a_xor8hex
8-hex-character FNV-1a digest of the input, suitable for inclusion in per-event log lines as a stable “what worker is this” identifier. The upper and lower 32 bits of the 64-bit hash are XOR-folded before hex formatting to keep both halves’ entropy in the 8 chars.