Dashboard › binpatch › Distillation
Distillation
ID: c390fa8f-e7a7-4297-bd7a-fa45051f9923
Generation: 0
Tokens: 599
R_compression: 9.491
C_norm: 0.008
Archived: No
Created: 2026-07-30 21:26:49
Source IDs:
["6e537bbf7c15134279816f360158e691","cbc03a272585c13dfc70b011a183172e","3dc270fb8564fbdae278fc3e1d1d2ea2","7e0a0f77496c4c4118aa11d26904ceae","b6f8f4fe7be3922cd6571b0b73e6439a"]
Observations
Date: July 30, 2026
- 🟡 (21:25) SWAR benchmark results: naive byte loop median 279.6 ms (357.6 MiB/s, runs [270.7, 279.6, 281.2, 284.1, 275.8]). Uint32Array SWAR (4×) median 144.7 ms (691.0 MiB/s, runs [144.7, 141.4, 146.7, 145.3, 139.5]). BigUint64Array SWAR (8×) median 127.6 ms (783.6 MiB/s, runs [127.6, 128.9, 126.9, 123.7, 128.2]).
- 🟡 (21:25) SWAR benchmark speedup vs naive: Uint32Array SWAR 1.93×, BigUint64Array SWAR 2.19×.
- 🟡 (21:25) Correctness verification: BigUint64Array SWAR implementation is actually CORRECT, not wrong as user expected. Verified across (a) 4096-byte sample with ~95% zero diff, (b) all bytes 0xff stress test (65536 pairs), (c) 1,000,000 random 8-byte pairs, (d) cross-byte carry stress (4×0x7f × 0xff byte pattern). All tests passed for both Uint32 and BigUint64 implementations.
- 🟡 (21:25) Mathematical explanation: SWAR trick
((a & mask) + (b & mask)) ^ ((a ^ b) & sign) with mask=0x7f7f7f7f is correct per byte lane because the 0x7f mask strips each byte's high bit, preventing cross-byte carry propagation. Lane width (4 vs 8 bytes) affects throughput only, not correctness. The formula in src/bspatch.ts:520 lifted to 8-byte lanes is mathematically equivalent to the 4-byte version.
- 🟡 (21:25) Benchmark setup details: 100 MB buffer, narrow-gap diff (~95% zero diff bytes), 5 independent runs, 5 reps per run, 3×8 MB warm-up iterations before measurement (JIT + GC stabilization). Per-run time = single-call median across reps.
- 🟡 (21:25) Benchmark script location: /tmp/opencode/swar-bench.mjs (extended with additional correctness verification tests beyond the original 4096-byte sample).
- 🟢 (21:25) User's premise about BigUint64Array carry issue was incorrect — the 0x7f per-byte mask prevents cross-byte carries regardless of lane width.