mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
A column walk reads one sample per row at a stride of `w * n`, so every sample pulls its own cache line and uses `n * 4` of its 64 bytes: 8x the image's traffic on a 1122-wide RGBA buffer. That is the pass that costs twice the row pass, and it was the largest remaining cost in Reduce Noise and Relight. `box_cols_n` now gathers up to `STRIP_BYTES` (64 KiB, L2-resident) of neighbouring columns into a transposed scratch, so reading a row costs one cache line instead of one per column, runs the same running sum over contiguous runs, and writes back. Below two columns per strip the gather costs more than it saves and the old strided walk stays, which is why a 6000x4000 buffer still takes it. This is the pattern `selection_blur.rs` already uses for its vertical pass. Same pixels: each column is still summed in `y` order with the same `f64` accumulator, and the same head/middle/tail split applies per column. `fxutil::tests::cols_match_the_strided_walk` compares every `f32` bit against the strided walk, including the 0x0, 5x0, `r = 0` and `r > h` edges, and all 16 `bench_filters2` rows hash identically to the base tree. The column pass is 1.73-1.89x faster. With the row pass from the parent commit, end to end on a 6000x4000 RGBA8 layer: Reduce Noise 1.48x, Tilt-Shift 1.41x, Relight 1.37x, Oil Paint 1.04x. See docs/box-blur-performance.md for the per-pass table, the discarded variants and the structural levers the remaining budget gap needs.