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: Holds the #1 Equivalence Crown across 4 functionally identical implementations (fastest verified hardware _rdtsc). Low-latency L1-resident kernel (277647/20000 cyc/op); well-suited for high-frequency pipeline stages.
Snap-Circuit Wiring Role: Slice Ingress / Scanner Stage `(&[u8])->u64` — digests raw byte buffers into scalar tokens or checksums.
.text: 442 B (105 x86_64 insns)1357 B)pub fn wupz_xor_fold(bytes: &[u8]) -> u64 {
let mut a0 = 0u64;
let mut a1 = 0u64;
let mut a2 = 0u64;
let mut a3 = 0u64;
let mut chunks64 = bytes.chunks_exact(64);
for c in &mut chunks64 {
a0 ^= u64::from_le_bytes([c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]])
^ u64::from_le_bytes([c[32], c[33], c[34], c[35], c[36], c[37], c[38], c[39]]);
a1 ^= u64::from_le_bytes([c[8], c[9], c[10], c[11], c[12], c[13], c[14], c[15]])
^ u64::from_le_bytes([c[40], c[41], c[42], c[43], c[44], c[45], c[46], c[47]]);
a2 ^= u64::from_le_bytes([c[16], c[17], c[18], c[19], c[20], c[21], c[22], c[23]])
^ u64::from_le_bytes([c[48], c[49], c[50], c[51], c[52], c[53], c[54], c[55]]);
a3 ^= u64::from_le_bytes([c[24], c[25], c[26], c[27], c[28], c[29], c[30], c[31]])
^ u64::from_le_bytes([c[56], c[57], c[58], c[59], c[60], c[61], c[62], c[63]]);
}
let mut acc = (a0 ^ a1) ^ (a2 ^ a3);
let mut chunks8 = chunks64.remainder().chunks_exact(8);
for c in &mut chunks8 {
acc ^= u64::from_le_bytes([c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]]);
}
let rem = chunks8.remainder();
if !rem.is_empty() {
let mut tail = [0u8; 8];
tail[..rem.len()].copy_from_slice(rem);
acc ^= u64::from_le_bytes(tail);
}
acc
}
rustc -C opt-level=3 x86_64 Disassembly (442 B .text / 105 insns)wupz_xor_fold:
push rbx
sub rsp, 16
movabs rcx, 9223372036854775744
and rcx, rsi
je .LBB7_1
lea r8, [rsi - 64]
test r8b, 64
jne .LBB7_3
lea rax, [rdi + 64]
lea rdx, [rcx - 64]
movdqu xmm1, xmmword ptr [rdi]
movdqu xmm2, xmmword ptr [rdi + 16]
movdqu xmm0, xmmword ptr [rdi + 32]
pxor xmm0, xmm1
movdqu xmm1, xmmword ptr [rdi + 48]
pxor xmm1, xmm2
cmp r8, 64
jae .LBB7_6
jmp .LBB7_8
.LBB7_1:
xor ebx, ebx
jmp .LBB7_9
.LBB7_3:
pxor xmm0, xmm0
mov rax, rdi
mov rdx, rcx
pxor xmm1, xmm1
cmp r8, 64
jb .LBB7_8
.LBB7_6:
xor r8d, r8d
.LBB7_7:
movdqu xmm2, xmmword ptr [rax + r8]
pxor xmm2, xmm0
movdqu xmm0, xmmword ptr [rax + r8 + 16]
pxor xmm0, xmm1
movdqu xmm1, xmmword ptr [rax + r8 + 32]
movdqu xmm3, xmmword ptr [rax + r8 + 48]
movdqu xmm4, xmmword ptr [rax + r8 + 80]
pxor xmm4, xmm3
pxor xmm4, xmm0
movdqu xmm3, xmmword ptr [rax + r8 + 64]
pxor xmm3, xmm1
pxor xmm3, xmm2
movdqu xmm0, xmmword ptr [rax + r8 + 96]
pxor xmm0, xmm3
movdqu xmm1, xmmword ptr [rax + r8 + 112]
pxor xmm1, xmm4
sub r8, -128
cmp rdx, r8
jne .LBB7_7
.LBB7_8:
pxor xmm0, xmm1
pshufd xmm1, xmm0, 238
pxor xmm1, xmm0
movq rbx, xmm1
.LBB7_9:
lea rax, [rdi + rcx]
mov edx, esi
and edx, 7
and esi, 56
je .LBB7_17
lea r10, [rsi - 8]
cmp r10, 24
jae .LBB7_12
mov r8, rsi
mov r9, rax
jmp .LBB7_15
.LBB7_12:
shr r10, 3
inc r10
mov r11, r10
and r11, -4
lea r9, [8*r11]
mov r8, rsi
sub r8, r9
lea r9, [rax + 8*r11]
movq xmm1, rbx
add rcx, rdi
add rcx, 16
pxor xmm0, xmm0
xor edi, edi
.LBB7_13:
movdqu xmm2, xmmword ptr [rcx + 8*rdi - 16]
pxor xmm1, xmm2
movdqu xmm2, xmmword ptr [rcx + 8*rdi]
pxor xmm0, xmm2
add rdi, 4
cmp r11, rdi
jne .LBB7_13
pxor xmm0, xmm1
pshufd xmm1, xmm0, 238
pxor xmm1, xmm0
movq rbx, xmm1
cmp r10, r11
je .LBB7_17
.LBB7_15:
xor ecx, ecx
.LBB7_16:
xor rbx, qword ptr [r9 + rcx]
add rcx, 8
cmp r8, rcx
jne .LBB7_16
.LBB7_17:
test rdx, rdx
je .LBB7_19
add rax, rsi
mov qword ptr [rsp + 8], 0
lea rdi, [rsp + 8]
mov rsi, rax
call qword ptr [rip + memcpy@GOTPCREL]
xor rbx, qword ptr [rsp + 8]
.LBB7_19:
mov rax, rbx
add rsp, 16
pop rbx
ret
| Global Rank | Capsule & Domain | Hardware _rdtsc | Latency | Throughput | ELF .text | Ternary Vote | Author Aye |
|---|---|---|---|---|---|---|---|
| #1638 | wupz_xor_fold (THIS CAPSULE) domain: smart-tree | id: b1b0f9a58585ab9287dc3d2acdbc79f6 | 277647/20000 cyc/op | 2644609/400000 ns/op | 400000000/2644609 ops/us | 442 B .text (105 insns) | + (1) | aye::Hue+Gemini(0+1)::x86_64 @ 432Hz |
| #1649 | reference_fold domain: smart-tree | id: 6ba1e9237f06ee601d37cac7ed14f659 | 1554087/100000 cyc/op | 370067/50000 ns/op | 50000000/370067 ops/us | 192 B .text (58 insns) | + (1) | aye::Hue+Gemini(0+1)::x86_64 @ 432Hz |
| #1675 | wupz_xor_fold_bytes domain: 8b-is-x86_64 | id: 6062182496ead4dfeef2de489087d5e2 | 91627/5000 cyc/op | 698261/80000 ns/op | 80000000/698261 ops/us | 512 B .text (121 insns) | + (1) | aye::Hue+Gemini(0+1)::x86_64 @ 432Hz |
| #1678 | xor_fold_scalar domain: smart-tree | id: 578a8eb4d4145dde7f6c8b036ac555f7 | 3886171/200000 cyc/op | 3701653/400000 ns/op | 400000000/3701653 ops/us | 153 B .text (42 insns) | + (1) | aye::Hue+Gemini(0+1)::x86_64 @ 432Hz |