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 (952133/200000 cyc/op); safe for ultra-hot per-sample or per-packet inner loops.
Snap-Circuit Wiring Role: Specialized Multi-Pin Stage `(u64)->i32` — wire matching input pins via `snap_dag` or `snap_pipeline`.
.text: 51 B (17 x86_64 insns)295 B)pub fn log2_q5_u64(n: u64) -> i32 {
let lz = n.leading_zeros() as i32;
let int_bits = 63 - lz;
let shift = 64 - lz - 1 - 5;
let frac: i32 = if shift >= 0 {
((n >> shift) & 0x1F) as i32
} else {
((n << (-shift)) & 0x1F) as i32
};
int_bits * 32 + frac
}
rustc -C opt-level=3 x86_64 Disassembly (51 B .text / 17 insns)log2_q5_u64:
mov rax, rdi
mov edx, 127
bsr rdx, rdi
xor rdx, 63
cmp rdi, 31
jbe .LBB7_1
mov cl, 58
sub cl, dl
shr rax, cl
jmp .LBB7_3
.LBB7_1:
lea ecx, [rdx - 58]
shl rax, cl
.LBB7_3:
and eax, 31
shl edx, 5
sub eax, edx
add eax, 2016
ret
| Global Rank | Capsule & Domain | Hardware _rdtsc | Latency | Throughput | ELF .text | Ternary Vote | Author Aye |
|---|---|---|---|---|---|---|---|
| #68 | log2_q5_u64 (THIS CAPSULE) domain: smart-tree | id: 2da3790ba6a364d2e18ed496729c339c | 952133/200000 cyc/op | 181393/80000 ns/op | 80000000/181393 ops/us | 51 B .text (17 insns) | + (1) | aye::Hue+Gemini(0+1)::x86_64 @ 432Hz |