Lab / failure
The harness was measuring itself
A benchmark of Weft's SAD kernel reported 15.16 ns at the smallest input. The real figure was 4.24 ns. The difference was 24 bytes the harness allocated per call, inside the timed region.
Measurement, Negative resultsWeft- Machine
- Apple M5 Max, 128-bit NEON
- Reported, 256 elements, before the fix
- 15.16 ns (invalid)
- Corrected, 256 elements
- 4.24 ns
- Allocated per call inside the timed region
- 24 bytes
Weft's SAD kernel, the block-compare an encoder runs constantly, benchmarked at 15.16 ns on its smallest input. The real figure is 4.24 ns.
The harness looked up the output buffer by name with a LINQ FirstOrDefault, which allocates, and it did that inside the timed region. Nothing was wrong with the kernel. The harness was billing its own bookkeeping to the code under test, and a fixed overhead hurts most where the kernel is shortest.
The lookup is allocation-free now and every row reports zero allocations. That same report turned out to have three more harness bugs in it. Apple M5 Max, date not noted.