Best Use & Engineering Application Guide

Engineering Category: Zero-Copy Scanning, Parsing & Codec Primitives

Best Use in Production: High-throughput byte-slice scanning, delimiter discovery, and wire-safe ASCII/hex transcoding inside bounded 64KB memory pages.

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

Snap-Circuit Wiring Role: 2-to-1 Binary Combiner / Join Stage `(u64,u64)->u64` — ideal for merging two upstream DAG branches, dot products, or pairwise rank fusion.

Hardware _rdtsc: 1320749/400000 cycles/op
Latency: 1258209/800000 ns/op
Throughput: 800000000/1258209 ops/us
Compiled ELF64 .text: 70 B (20 x86_64 insns)
C64 64KB RAM Budget: 193/32768 (386 B source)
Ternary Vote: + (score 1) | Salience: 9445/114
Pure-Rust Capsule Source Code (386 B)
#[inline(always)]
pub fn binary_search_eytzinger_u64(packed_sorted: u64, needle: u64) -> u64 {
    let mut k: u32 = 1;
    while k <= 7 {
        let shift = (k - 1) * 8;
        let val = (packed_sorted >> shift) & 0xFF;
        let step = ((needle >= val) as u32) & 1;
        k = (k << 1) + step;
    }
    let idx = (k >> (k.trailing_ones() + 1)).saturating_sub(1);
    idx as u64
}
rustc -C opt-level=3 x86_64 Disassembly (70 B .text / 20 insns)
binary_search_eytzinger_u64:
    mov    eax, 1
.LBB7_1:
    lea    ecx, [8*rax]
    add    cl, 56
    mov    rdx, rdi
    shr    rdx, cl
    movzx    ecx, dl
    xor    edx, edx
    cmp    rsi, rcx
    setae    dl
    cmp    eax, 4
    lea    eax, [rdx + 2*rax]
    jb    .LBB7_1
    mov    ecx, eax
    not    ecx
    rep        bsf    ecx, ecx
    inc    cl
    shr    eax, cl
    cmp    eax, 1
    adc    eax, -1
    ret

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

Global RankCapsule & DomainHardware _rdtscLatencyThroughputELF .textTernary VoteAuthor Aye
#37binary_search_eytzinger_u64 (THIS CAPSULE)
domain: search | id: 5fc7c25762e754d9018729c322c172f1
1320749/400000 cyc/op1258209/800000 ns/op800000000/1258209 ops/us70 B .text (20 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz