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. Multi-step compute kernel (5016701/100000 cyc/op); best used at frame, block, or batch aggregation boundaries.

Snap-Circuit Wiring Role: Slice Ingress / Scanner Stage `(&[u8])->u32` — digests raw byte buffers into scalar tokens or checksums.

Hardware _rdtsc: 5016701/100000 cycles/op
Latency: 298631/12500 ns/op
Throughput: 12500000/298631 ops/us
Compiled ELF64 .text: 235 B (60 x86_64 insns)
C64 64KB RAM Budget: 197/65536 (197 B source)
Ternary Vote: + (score 1) | Salience: 17515/216
Pure-Rust Capsule Source Code (197 B)
pub fn adler32(data: &[u8]) -> u32 {
    let (mut a, mut b) = (1u32, 0u32);
    for &byte in data {
        a = (a + u32::from(byte)) % 65521;
        b = (b + a) % 65521;
    }
    (b << 16) | a
}
rustc -C opt-level=3 x86_64 Disassembly (235 B .text / 60 insns)
adler32:
    test    rsi, rsi
    je    .LBB7_1
    cmp    rsi, 1
    jne    .LBB7_4
    xor    eax, eax
    mov    ecx, 1
    jmp    .LBB7_7
.LBB7_1:
    mov    eax, 1
    ret
.LBB7_4:
    movabs    rdx, 9223372036854775806
    and    rdx, rsi
    xor    eax, eax
    mov    ecx, 1
    mov    r8d, 2147975281
.LBB7_5:
    movzx    r9d, byte ptr [rdi]
    add    r9d, ecx
    mov    rcx, r9
    imul    rcx, r8
    shr    rcx, 47
    imul    ecx, ecx, 65521
    sub    r9d, ecx
    add    eax, r9d
    mov    rcx, rax
    imul    rcx, r8
    shr    rcx, 47
    imul    ecx, ecx, 65521
    sub    eax, ecx
    movzx    ecx, byte ptr [rdi + 1]
    add    rdi, 2
    add    ecx, r9d
    imul    r9, rcx, 131103
    shr    r9, 33
    imul    r9d, r9d, 65521
    sub    ecx, r9d
    add    eax, ecx
    imul    r9, rax, 131103
    shr    r9, 33
    imul    r9d, r9d, 65521
    sub    eax, r9d
    add    rdx, -2
    jne    .LBB7_5
    test    sil, 1
    je    .LBB7_8
.LBB7_7:
    movzx    edx, byte ptr [rdi]
    add    edx, ecx
    mov    ecx, 2147975281
    mov    rsi, rdx
    imul    rsi, rcx
    shr    rsi, 47
    imul    esi, esi, 65521
    sub    edx, esi
    add    eax, edx
    imul    rcx, rax
    shr    rcx, 47
    imul    ecx, ecx, 65521
    sub    eax, ecx
    mov    ecx, edx
.LBB7_8:
    shl    eax, 16
    or    eax, ecx
    ret

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

Global RankCapsule & DomainHardware _rdtscLatencyThroughputELF .textTernary VoteAuthor Aye
#1709adler32 (THIS CAPSULE)
domain: smart-tree | id: 4118dc5ae907db5f5cf4b6f2138325f0
5016701/100000 cyc/op298631/12500 ns/op12500000/298631 ops/us235 B .text (60 insns)+ (1)aye::Hue+Gemini(0+1)::x86_64 @ 432Hz