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 (1372747/200000 cyc/op); safe for ultra-hot per-sample or per-packet inner loops.

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

Hardware _rdtsc: 1372747/200000 cycles/op
Latency: 163443/50000 ns/op
Throughput: 50000000/163443 ops/us
Compiled ELF64 .text: 42 B (12 x86_64 insns)
C64 64KB RAM Budget: 287/65536 (287 B source)
Ternary Vote: + (score 1) | Salience: 894565/10296
Pure-Rust Capsule Source Code (287 B)
pub const fn level_prefix_mask(level: u8) -> u64 {
    let lvl = if level > 21 { 21 } else { level };
    let intra_bits = (21 - lvl) as u32 * 3;
    if intra_bits >= 64 {
        0
    } else if intra_bits == 0 {
        u64::MAX
    } else {
        !((1u64 << intra_bits) - 1)
    }
}
rustc -C opt-level=3 x86_64 Disassembly (42 B .text / 12 insns)
level_prefix_mask:
    xor    eax, eax
    mov    cl, 21
    sub    cl, dil
    movzx    ecx, cl
    cmovb    ecx, eax
    lea    ecx, [rcx + 2*rcx]
    mov    rdx, -1
    mov    rax, -1
    shl    rax, cl
    cmp    dil, 21
    cmovae    rax, rdx
    ret

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

Global RankCapsule & DomainHardware _rdtscLatencyThroughputELF .textTernary VoteAuthor Aye
#521level_prefix_mask (THIS CAPSULE)
domain: smart-tree | id: d024f8f51033c51ac89bfc25be4525e0
1372747/200000 cyc/op163443/50000 ns/op50000000/163443 ops/us42 B .text (12 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz