Best Use & Engineering Application Guide

Engineering Category: Lossless Wire & Structural Compression

Best Use in Production: Zero-allocation integer bit-packing, variable-length encoding, and stream framing for sovereign wire protocols.

When to Select This Capsule: Sole canonical implementation for its 64-vector functional equivalence class. Sub-10-cycle hardware kernel (960779/200000 cyc/op); safe for ultra-hot per-sample or per-packet inner loops.

Snap-Circuit Wiring Role: Specialized Multi-Pin Stage `(u64,u64)->u32` — wire matching input pins via `snap_dag` or `snap_pipeline`.

Hardware _rdtsc: 960779/200000 cycles/op
Latency: 11441/5000 ns/op
Throughput: 5000000/11441 ops/us
Compiled ELF64 .text: 93 B (21 x86_64 insns)
C64 64KB RAM Budget: 75/65536 (75 B source)
Ternary Vote: + (score 1) | Salience: 250/3
Pure-Rust Capsule Source Code (75 B)
pub fn hamming_distance(a: u64, b: u64) -> u32 {
    (a ^ b).count_ones()
}
rustc -C opt-level=3 x86_64 Disassembly (93 B .text / 21 insns)
hamming_distance:
    xor    rdi, rsi
    mov    rax, rdi
    shr    rax
    movabs    rcx, 6148914691236517205
    and    rcx, rax
    sub    rdi, rcx
    movabs    rax, 3689348814741910323
    mov    rcx, rdi
    and    rcx, rax
    shr    rdi, 2
    and    rax, rdi
    add    rax, rcx
    mov    rcx, rax
    shr    rcx, 4
    add    rcx, rax
    movabs    rdx, 1085102592571150095
    and    rdx, rcx
    movabs    rax, 72340172838076673
    imul    rax, rdx
    shr    rax, 56
    ret

Head-to-Head Functional Equivalence Class Peers (1 Implementation(s) Matching 64 Test Vectors)

Global RankCapsule & DomainHardware _rdtscLatencyThroughputELF .textTernary VoteAuthor Aye
#66hamming_distance (THIS CAPSULE)
domain: smart-tree | id: 34750981dc46d51103150e816652ff29
960779/200000 cyc/op11441/5000 ns/op5000000/11441 ops/us93 B .text (21 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz