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 (878401/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: 878401/400000 cycles/op
Latency: 52307/50000 ns/op
Throughput: 50000000/52307 ops/us
Compiled ELF64 .text: 77 B (26 x86_64 insns)
C64 64KB RAM Budget: 55/8192 (440 B source)
Ternary Vote: + (score 1) | Salience: 3395/36
Pure-Rust Capsule Source Code (440 B)
#[inline(always)]
pub fn binary_search_branchless_u64(packed_sorted: u64, needle: u64) -> u64 {
    let mut base: u32 = 0;
    let mid4 = (packed_sorted >> ((base + 4) * 8)) & 0xFF;
    base += ((needle >= mid4) as u32) * 4;
    let mid2 = (packed_sorted >> ((base + 2) * 8)) & 0xFF;
    base += ((needle >= mid2) as u32) * 2;
    let mid1 = (packed_sorted >> ((base + 1) * 8)) & 0xFF;
    base += (needle >= mid1) as u32;
    base as u64
}
rustc -C opt-level=3 x86_64 Disassembly (77 B .text / 26 insns)
binary_search_branchless_u64:
    mov    rax, rdi
    shr    rax, 32
    movzx    eax, al
    xor    edx, edx
    cmp    rsi, rax
    setae    dl
    mov    ecx, edx
    shl    ecx, 5
    or    cl, 16
    mov    rax, rdi
    shr    rax, cl
    movzx    eax, al
    xor    ecx, ecx
    cmp    rsi, rax
    setae    cl
    shl    edx, 2
    lea    edx, [rdx + 2*rcx]
    lea    ecx, [8*rdx]
    or    cl, 8
    shr    rdi, cl
    movzx    ecx, dil
    xor    eax, eax
    cmp    rsi, rcx
    setae    al
    or    eax, edx
    ret

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

Global RankCapsule & DomainHardware _rdtscLatencyThroughputELF .textTernary VoteAuthor Aye
#16binary_search_branchless_u64 (THIS CAPSULE)
domain: search | id: bf95176a63b04e400048335d7fc1ee91
878401/400000 cyc/op52307/50000 ns/op50000000/52307 ops/us77 B .text (26 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz