forge
Explore
Log in

Don't you dare go Hollow

Commits

Commits on f89b1a2200b9437fa401cdea6aa03918ce4e5725

2026-09-05

perf(av1): film grain writes its output once, from the bandsAhmet Kaan Gümüş · 8db0d01
perf(av1): film grain writes its output once, from the bands

apply_grain cloned the whole clean picture on the frame thread and then
wrote the noise over the copy -- a serial 25 MB memmove per 4K frame
ahead of the parallel block-row walk. The grain bands already own a
partition of the picture's rows, so each band now copies its own rows
out of the clean source one block row AHEAD of the noise it adds to
them: the copy runs on the filter pool, the rows the kernels read back
are still in the core's cache, and the destination is allocated
uninitialised instead of cloned or zeroed.

Byte-exact: 12/12 gate hashes at 1, 4 and 16 threads, plus a real
film-cut decode at (16,4,2) hashing identical to the base binary. seg4k
at (16,4,2), 4 interleaved rounds: task-clock 48.50/47.07/46.62/45.34 s
base -> 46.44/45.12/45.74/44.76 s, -1.3..-4.2% every round; instructions
408.385 -> 408.404 G (flat); page-faults flat. At 1 thread task-clock
36.98 -> 32.41 s.
perf(av1): the wavefront's op list and prediction buffers are reused per blockAhmet Kaan Gümüş · e1f00c9
perf(av1): the wavefront's op list and prediction buffers are reused per block

`wave_submit` took the recorded op list and left a zero-capacity `Vec`
behind, so every superblock regrew it -- and memmoved every op already
recorded -- from nothing; it is now replaced sized for the next
superblock, exactly as the two arenas beside it already were.

A deferred prediction build returned three fresh `Vec<u16>` per block
and dropped the previous three; the build now refills the buffers the
worker already holds (`refill`, which still allocates zeroed when the
buffer has to grow, since `calloc` beats an element-wise resize).

Byte-exact 12/12 at 1/4/16 threads. seg4k instructions:u at (16,4,2)
409.809 -> 408.259 G (-0.38%); at 1 thread 404.579 -> 405.005 G
(+0.11%, the inline path has no previous buffer to reuse and pays the
plumbing) -- kept for the threaded config the 4K target names.
perf(av1): skipped blocks stop allocating and copying their zero coefficient gridsAhmet Kaan Gümüş · bccf2c8
perf(av1): skipped blocks stop allocating and copying their zero coefficient grids

A skipped block handed every consumer a freshly heap-allocated all-zero
level grid -- up to 64 KB per block, three of them for the neighbour
record and one per plane for the recorded write. Those buffers are
read-only at every consumer, so they are now the existing static
`ZERO_RESIDUAL` slice: `Neighbours::record*` takes `&[&[i32]; 3]`
instead of owning Vecs, and the 53 `&vec![0i32; n]` argument
temporaries index the static instead.

`Residual::done` recognises that slice by pointer and records the
all-zero marker `Done(0, 0)` (the one `Residual::coeffs` already
produces), so a skipped block no longer copies its zeros into the
coefficient arena either.

Byte-exact 12/12 at 1/4/16 threads. seg4k instructions:u 414.794 ->
409.809 G at (16,4,2) (-1.2%), 406.145 -> 404.579 G at 1 thread
(-0.39%); page-faults 1.034 -> 1.014 M at (16,4,2).
perf(av1): padded coefficient level buffers, stack-allocated rect levelsAhmet Kaan Gümüş · 3fdf4ac
perf(av1): padded coefficient level buffers, stack-allocated rect levels

read_coeffs / read_coeffs_rect pad their level buffer the way libaom's own
does (TX_PAD_HOR/TX_PAD_VER): a fixed stride of side + 4 columns and four
spare rows, all zero and never written, so the five neighbour reads
base_ctx/br_ctx make per coefficient index the buffer unconditionally
instead of running the row >= side || col >= side edge test. The rect
reader's per-unit heap vec![0; w * h] becomes a stack frame sized to the
padded unit, and its pos / w, pos % w a shift and a mask.

Byte-exact: 12/12 gate hashes at 1/4/16 threads. instructions:u on the 4K
segment -0.53% at one thread (412.376 -> 410.195 G) and -0.51% at
(16,4,2) (422.503 -> 420.353 G).
perf(av1): 24-byte mi grid cellAhmet Kaan Gümüş · 5ba1d08
perf(av1): 24-byte mi grid cell

`MiInfo` is one cell per 4x4 unit of the frame and `find_mv_stack` walks it
for every inter block, so the cell's size is that scan's memory traffic. The
second reference slot carried two `Option` tag words (`ref_frame1`, `mv1`);
slot 1 only ever holds a real reference, so `NO_REF1` (-1) tags it absent and
`mv1` becomes a plain pair -- 32 -> 24 bytes, `is_inter` still giving
`Option<MiInfo>` a niche so the grid cell costs no extra word. An interintra
neighbour (slot 1 = INTRA_FRAME, no second MV) was excluded by its `mv1`
being `None` and is now excluded by `ref_frame1 > 0`, the same condition
libaom's own ref-diff scan uses.

Byte-exact: all 12 gate hashes (4 streams x 1/4/16 threads) unchanged.
instructions:u on the 4K segment 410.629 -> 410.478 G at 1 thread,
419.746 -> 419.481 G at (16,4,2); task-clock at (16,4,2) 42.41 -> 41.81 s
against the lane base.
perf(av1): the saved motion field builds off the frame thread, one other-side table per frameAhmet Kaan Gümüş · 259f3b7
perf(av1): the saved motion field builds off the frame thread, one other-side table per frame

`build_motion_field` (libaom `av1_copy_frame_mvs`) was a serial whole-frame
4x4-unit pass on the frame thread that re-evaluated the `other_side`
order-hint comparison for every reference slot of every inter unit.

Two changes, both output-identical:

* the per-reference `other_side` answer is a `[bool; 8]` computed once per
  frame instead of two `get_relative_dist` calls per inter unit;
* the pass is split into cell-row bands over the filter pool with the
  existing `par::bands`/`Shared`/`run_bands` pattern. An 8x8 motion-field
  cell lives entirely in one cell row, so a band owns `cells[r0 * cols..r1 *
  cols]` and no two bands ever touch the same cell -- the write order inside
  a band is unchanged, so the "last qualifying slot wins" and
  "clear-then-maybe-write" semantics are preserved exactly.

The field is consumed only by LATER frames, never by this frame's entropy
decode; it is published as part of `SlotValue` at `SlotPromise::fulfil`, so it
cannot be deferred past the fulfil without splitting that publication.

seg4k, 4dc14f52 -> here: instructions:u 412.358 -> 410.565 G at 1 thread
(-0.44%, the hoist alone -- bands collapse to 1 at FILTER_THREADS=1) and
421.45 -> 419.13 G at (16,4,2) (-0.55%). All 12 gate hashes unchanged at 1, 4
and 16 threads.
perf(av1): heap-free MV stack and row-fill mi publicationAhmet Kaan Gümüş · fc982db
perf(av1): heap-free MV stack and row-fill mi publication

The MV stack was two heap allocations per inter block (`entries` plus
`drl_ctx`); both lists are bounded by a spec constant, so they move into a
fixed-capacity inline `SmallVec` that derefs to the same slice API. Mode-info
publication stamped its block footprint cell by cell through `MiGrid::set`;
rows are contiguous, so `MiGrid::fill_rect` fills each row with one
`slice::fill` of the `Copy` cell instead.

Byte-exact: all four gate streams hash unchanged at 1 thread.
instructions:u on the 4K segment 412.376 -> 410.629 G at 1 thread,
421.419 -> 419.746 G at (16,4,2).
perf(av1): hoist the temporal-MV probe out of the per-sample loop, thread-local the mvstack gate countersAhmet Kaan Gümüş · e08e4e4
perf(av1): hoist the temporal-MV probe out of the per-sample loop, thread-local the mvstack gate counters

`add_tpl_ref_mv` re-derived the parity, the field bounds and the row base
on every one of the (up to 19) 8x8 probes a query block makes. Those are
per-BLOCK quantities: `row8 = mi_row + blk_row + (mi_row even)` means the
cell index is `(mi_row + 1 - (mi_row & 1) + blk_row) >> 1`, and an
arithmetic shift keeps the spec's `row8 < 0` rejection exact. `TplProbe`
holds the two bases plus the cell slice, so a probe is an add, a shift and
a bounds check; the compound stack reads the cell ONCE and projects it to
both sides instead of walking the field twice. `EC_TRACE_TPL`'s per-sample
dump is unchanged: the flag is read once per block and the traced path
still goes through `add_tpl_ref_mv` itself.

The four mvstack firing counters (`TMV_HITS` per inter block,
`STACK_FULL_DROPS` per candidate insertion, `COMP_GM_FILL_HITS`,
`TILE_REACH_CLIPS`) were process-global atomics: one shared cache line
bumped by 16 frame threads on the parse critical path. They are now
thread-local `Cell`s, the form every other gate counter in the crate
already uses; the gates that read them decode on their own thread.

-0.21% instructions on the 4K segment at 1 thread (443.29 vs 444.24 G);
the counter step is flat there and inside the box's noise at 16 threads.
Byte-exact: all 12 gate hashes unchanged at 1/4/16 threads.
perf(av1): an all-zero inter residual reconstructs as a prediction copyAhmet Kaan Gümüş · c5b674a
perf(av1): an all-zero inter residual reconstructs as a prediction copy

`reconstruct_mc_rect` expanded the empty all-zero marker into a `side * h`
slice of the 64 KB `ZERO_RESIDUAL` static and added those zeros sample by
sample -- for 60% of the units. The zero case now runs the same clamp
without the residual operand (identical arithmetic at `r == 0`; the
prediction->plane copy the charter names is kept).

instructions:u on the 4K segment: 453.00 G -> 450.45 G at (16, 4, 2)
threads, 444.33 G -> 441.90 G at one thread.
perf(av1): intra edges on the stackAhmet Kaan Gümüş · ee5b8d8
perf(av1): intra edges on the stack

An edge is at most bw + bh + 1 = 129 samples, so Edges holds two arrays
instead of two heap buffers, and the edge filter's working copy is a
stack array too: two allocations gone per predicted block, on a stream
whose intra blocks are mostly 4x4 to 16x16.

Byte-exact on all four gate streams; -0.07% instructions on the 4K
segment, -0.08% on the 1080p one (malloc latency does not show on
instructions:u).
perf(av1): recorded reconstruction ops index per-superblock arenas instead of owning a Vec eachAhmet Kaan Gümüş · ba6ddd4
perf(av1): recorded reconstruction ops index per-superblock arenas instead of owning a Vec each

A recorded transform unit copied its coefficient grid (`grid.to_vec()`) and
a recorded motion-compensated write copied its prediction window into a
fresh `Vec`, both on the parse thread, both freed on a recon worker: ~7.1 M
malloc/free pairs across the 4K segment, with `_int_malloc` on the frame
thread and `_int_free_chunk` on the workers.

The tile now carries two arenas (`FrameCtx::coeff_arena`, `pred_arena`); a
record is an `(offset, len)` into them. They are handed over WITH the ops at
both drain points -- `wave_submit` moves them into the job (`ReconJob`), so
one buffer per superblock reaches the worker instead of one per unit, and
`flush_recon` swaps them through spares -- which keeps every offset relative
to the live arena and every write byte-identical.

instructions:u on the 4K segment at (16 frame, 4 filter, 2 recon) threads:
456.25 G -> 453.00 G (-0.72%); wall on this box is load-dominated and does
not resolve it.
perf(av1): directional intra hoists the zone, the derivative and the blend out of the pixel loopAhmet Kaan Gümüş · e7ac08e
perf(av1): directional intra hoists the zone, the derivative and the blend out of the pixel loop

The z1/z2/z3 walk decided its zone, looked the derivative up in a
27-arm match and called the edge blend through a `&dyn Fn` once per
sample. Three loops, one per zone, with the derivative and the base
constants per block and z1's shift per row; the blend indexes the edge
slice directly.

Byte-exact on all four gate streams. -0.25% instructions on the 4K
segment, -0.47% on the 1080p one (cumulative -2.84% / -1.97%).
perf(av1): intra non-directional prediction loops once per mode, not per pixelAhmet Kaan Gümüş · 29faade
perf(av1): intra non-directional prediction loops once per mode, not per pixel

The seven non-directional modes shared one pixel loop with a 13-arm
`match mode` inside it, so every sample re-ran the dispatch and DC_PRED
re-averaged both edges per sample. One loop per mode instead, with the
per-row terms (smooth weights, the bottom-left/top-right anchors, the
left column sample) hoisted out of the column loop.

Byte-exact: all four gate streams hash to their references at 1 thread.
-2.59% instructions on the 4K segment, -1.51% on the 1080p one.
perf(av1): the compound vertical pass runs the whole block per callAhmet Kaan Gümüş · f2203de
perf(av1): the compound vertical pass runs the whole block per call

vpass_row takes the block's row count too, and the compound kernel
accumulates straight into its i32 destination and rounds it in one
sweep, dropping the per-row accumulator round trip along with the
per-row tap setup. Byte-exact: all four gate streams hash to their
references.
perf(av1): the vertical pass sets its taps up once per block, not once per rowAhmet Kaan Gümüş · 3702d63
perf(av1): the vertical pass sets its taps up once per block, not once per row

vpass_row_u16 and its AVX2/SSE4.1 kernels take the block's row count, so
the tap pairs, the rounding vector and the clamp vector are built once
per predict call. Byte-exact: all four gate streams hash to their
references.
perf(av1): the horizontal pass sets its taps up once per block, not once per rowAhmet Kaan Gümüş · e27ea46
perf(av1): the horizontal pass sets its taps up once per block, not once per row

hpass_avx2/hpass_sse2 take the block's row count and source stride, so
the tap broadcast, the rounding vector and the SIMD dispatch happen once
per predict call instead of once for each of the block_h+7 rows.
Byte-exact: all four gate streams hash to their references.
perf(av1): MC hoists the interior row test and fuses whole-pel-horizontal blocks onto the referenceAhmet Kaan Gümüş · 37ae497
perf(av1): MC hoists the interior row test and fuses whole-pel-horizontal blocks onto the reference

The unscaled horizontal pass tested the vertical clamp, the interior
window, the slice bounds, the tap narrowing and the SIMD level once per
row; when the whole footprint is inside the reference -- the common case
-- every one of those has the same answer for all rows, so the test is
hoisted and the loop is a walk of the stride.

A whole-pel horizontal position makes the horizontal pass the identity
tap, whose intermediate is exactly `s << 4`, so the vertical pass is the
same 8-tap sum taken straight off the reference rows with the taps
scaled by 16. Both the single and the compound kernel now take that
path for interior blocks, which drops the intermediate entirely; the
vertical kernels gained a source-stride parameter to read it.

Byte-exact: all four gate streams hash to their references.
perf(av1): deblock kernel per length, level table per plane passAhmet Kaan Gümüş · b247733
perf(av1): deblock kernel per length, level table per plane pass

The AVX2 edge kernel is monomorphised on the edge length, so each of the
four lengths holds only its own taps live and every wide row is clamped
straight into the tile instead of into a shared twelve-entry result array
the register allocator spilled (35% -> 18% of the kernel's samples on
stack moves). An all-empty filter mask now returns without any write-back
at all, which also drops a vertical edge's second transpose.

edge_params' seven per-plane-pass arguments -- half of them passed on the
stack into the inline(never) body -- collapse into one EdgeCtx built once
per band, carrying libaom's av1_loop_filter_frame_init idea in level
form: get_filter_level for every (base level, ref frame) pair, tabulated
once instead of re-derived per 4-pixel edge group.

Byte-exact: all four gate streams hash identically at 1, 4 and 16
threads.
perf(av1): CDEF direction search row-at-a-time, i16 filter windowsAhmet Kaan Gümüş · 8402ace
perf(av1): CDEF direction search row-at-a-time, i16 filter windows

`cdef_find_dir`'s 64-sample accumulation was 57% of `cdef_band` (22.6% of
the function on decode.rs:15560 alone): 512 scalar read-modify-writes on
i64 partials. Each of libaom `cdef_find_dir_c`'s eight index forms is,
once the row is fixed, "add the row / its reverse / its pairwise sums /
its total into consecutive slots", so the loop is rewritten row at a time
over i32 partials (exact: a partial is at most eight samples in -128..127)
and gains an AVX2 twin, `cdef_find_dir_partials_avx2`, for eight lanes
instead of the four the scalar form auto-vectorises to.

`cdef_gather` now writes the window as i16, which is what the AVX2 tap
kernel wanted anyway: it taps the caller's 256-entry scratch in place
instead of copying and narrowing 144 entries per block.

Byte-exact: all four gate streams unchanged. seg4k instructions:u
504.77 -> 499.27 G (-1.09%); cdef_band 3.02% -> 1.78% of cycles.
New gate `cdef_find_dir_matches_the_per_sample_reference` pins both forms
against a literal transcription of `cdef_find_dir_c`, sentinel rows
included.
perf(av1): put the AVX2 feature on the Lane methods themselvesAhmet Kaan Gümüş · b848139
perf(av1): put the AVX2 feature on the Lane methods themselves

The column pass measured -3.7% instructions when the network was
`#[inline(always)]`d into the `target_feature` wrapper -- and then measured
FLAT again after an unrelated refactor moved the size dispatch into its own
`target_feature` function: the generic network stopped landing inside an AVX2
context, and with it every `_mm256_*` went back to being an out-of-line call
(9.5% + 3.7% of the profile, 65 `vpmuldq` in the binary against 339 now).

Relying on inlining to carry the feature is what was fragile. `Lane`'s two
methods are `unsafe fn` now -- the only form rustc lets an impl carry
`#[target_feature]` -- so the AVX2 impl compiles its intrinsics inline no
matter how its callers are arranged. The scalar impls require nothing of
their callers, and `M256` values still exist only inside the feature-detected
`simd::column_pass_dct`.

seg4k at one thread: 523.15 -> 502.36 G instructions:u (-3.97%), stable across
runs. All 12 gate hashes unchanged.
test(av1): the AVX2 column pass against the scalar network over the full i32 rangeAhmet Kaan Gümüş · 1b7f343
test(av1): the AVX2 column pass against the scalar network over the full i32 range

The intrinsics claim exact 64-bit products, so the gate sweeps `i32::MIN`/
`MAX`, both clamp boundaries at every `r` the decoder uses (16/18/20) and
uniform full-range noise at every size, not only the dequantizer's own bound
-- a single differing lane would be a silent pixel drift on whatever stream
first reached it.
perf(av1): explicit AVX2 inverse-DCT column pass, and an empty all-zero residualAhmet Kaan Gümüş · ef53b7e
perf(av1): explicit AVX2 inverse-DCT column pass, and an empty all-zero residual

The eight-wide column pass lane-tx introduced went through `[i32; 8]`, which
LLVM never vectorised (the butterfly products are 64-bit). This adds an
explicit AVX2 `Lane` impl -- `_mm256_mul_epi32` on the even/odd halves, so
every product is exact in 64 bits and the pass is byte-exact with the scalar
network on every input, not only on conformant ones -- dispatched off
`mc::simd_level()`, with the scalar impl kept as the reference.

`inverse_dct_n` is `#[inline(always)]` because the AVX2 instantiation has to
land inside the `target_feature` wrapper: without it every `_mm256_*` stayed
an out-of-line call and the "SIMD" pass measured 5.6% WORSE.

Second, the 60% of transform units that carry no coefficient now return an
EMPTY residual instead of `w * h` zeros: the reconstruction loops expand the
marker against one static zero block, so the per-unit zero `Vec`, its `to_vec`
clone into the recorded op, and (for a deferred unit) the coefficient-grid
clone all disappear.

seg4k at one thread: 523.1 -> 503.5 G instructions:u (-3.7%), min-of-5
cycles:u 142.1 -> 136.4 G. All 12 gate hashes unchanged.
perf(av1): constant-length row copies on the whole-pel inter pathAhmet Kaan Gümüş · 3a35e5f
perf(av1): constant-length row copies on the whole-pel inter path

A whole-pel prediction is a clamped copy, and its per-row
`copy_from_slice` compiled to a `memcpy` call with a runtime length --
for the 8-sample row of an 8x8 block (the most common inter shape on
real 4K content) the call costs more than the move it makes. The three
common widths get a constant length, which inlines.

-0.11% instructions on the 4K segment (523.67 -> 523.07 G at one
thread), -5.4% cumulative; all twelve gate hashes unchanged.
perf(av1): deblock -- masked transform-alignment gate, inlined edge_params head, running-sum filter14Ahmet Kaan Gümüş · 2a2adba
perf(av1): deblock -- masked transform-alignment gate, inlined edge_params head, running-sum filter14

Three measured steps on the loop filter, all byte-exact (the four gate
streams hash identically at 1, 4 and 16 threads):

1. `edge_params`' transform-alignment test was `coord % cur_tx`, a hardware
   `divl` whose result test carried 10.7% of the function's samples;
   `cur_tx` is a power of two, so it is a mask. -0.29% instructions.
2. That gate rejects most 4-pixel edge groups, so it is now inlined into the
   deblock loops and only survivors pay the call and the register-spilling
   prologue of `edge_params_body`. -1.83%.
3. The AVX2 kernel's wide-filter rows took their weights as slices, leaving a
   branch and a weight load per tap (`testl`/`je`/`movzwl` were 34% of the
   kernel's samples): `filter6`/`filter8` rows are unrolled with const
   weights, and `filter14`'s twelve rows become a running sum over the
   constant row-to-row deltas (168 tap operations -> 44). -1.50%.

seg4k at one thread: 553.30 -> 533.44 G instructions:u (-3.59%); the deblock
share of the 4K profile falls from ~7.3% to ~6.0% and the kernel itself from
4.00% to 2.52%. `deblock_simd_kernel_matches_the_scalar_filter` already pins
the kernel against the scalar `filter_edge` at 8/10/12-bit over every length,
level and sharpness.
perf(av1): fuse the inter vertical pass's rounding into its kernelAhmet Kaan Gümüş · 209d003
perf(av1): fuse the inter vertical pass's rounding into its kernel

The vertical pass stored a row of unrounded `i32` sums to a scratch
buffer that the very next loop read back to round, clamp and narrow to
the block's `u16` samples. The sums never need to reach memory:
`packus_epi32` IS the clamp's lower half (a negative sum saturates to
zero) and `min_epu16` its upper, so `round2(sum, InterRound1).clamp(0,
max)` is two instructions on the register the taps were accumulated in.

`vpass_row` keeps its unrounded form for the compound intermediate and
for restoration's wiener pass, whose roundings differ.

-1.7% instructions on the 4K segment (532.7 -> 523.7 G at one thread),
-5.3% cumulative for the lane; all four gate hashes unchanged.
perf(av1): 16-bit motion-compensation intermediate, vertical pass on maddAhmet Kaan Gümüş · ad664df
perf(av1): 16-bit motion-compensation intermediate, vertical pass on madd

The separable inter filter kept its horizontal output in `i32`, so the
vertical pass spent one `mullo_epi32` per tap per 8 columns and moved
twice the bytes it had to. The intermediate provably fits `i16` at the
bit depths this decoder accepts -- a phase's positive taps sum to at
most 156, so `Round2(1023 * 156, 3)` is 19948, and 12-bit (where
`InterRound0` itself changes) is refused in stream.rs. With the buffer
narrowed, a row PAIR interleaved by `unpack_epi16` is exactly
`madd_epi16`'s shape: two taps of 16 columns per instruction.

The horizontal kernels store through `packs_epi32`, whose saturation is
unreachable on a motion-compensation path (the new
`horizontal_intermediate_fits_i16` enumerates every filter kind, table
and phase to prove it) and composes with the wiener clamp on the
restoration path, whose bounds are inside `i16` at 8- and 10-bit.

-3.7% instructions on the 4K segment (553.2 -> 532.7 G at one thread);
all four gate hashes unchanged.
perf(av1): monomorphise the inverse DCT per size, take the column pass eight columns at a time, skip all-zero transform unitsAhmet Kaan Gümüş · 484b7c3
perf(av1): monomorphise the inverse DCT per size, take the column pass eight columns at a time, skip all-zero transform units

The inverse transform was ~10% of a 4K decode. Three measured steps, all
byte-exact (12/12 gate hashes at 1/4/16 threads unchanged):

- the spec's one generic butterfly network is now monomorphised on
  `N = log2(size)`, so every size guard, every `brev` fold and every
  butterfly angle is a compile-time constant instead of per-call work
  (-1.03%);
- the column pass runs eight neighbouring columns through one network
  (a `Lane` trait with an `i32` and an `[i32; 8]` impl, so the network
  itself is still written once), turning the strided per-column gather
  into a contiguous load (-2.67%);
- 60% of the transform units on the 4K perf segment carry no coefficient
  at all (3.46M of 5.7M, measured with a temporary histogram): a zero
  level grid dequantizes to zero and inverse-transforms to zero, so one
  scan replaces the dequantization and both passes (-1.55%).

Together 559.05 -> 530.19 G instructions:u at one thread on the 4K
segment, -5.16%.

Two steps measured flat and are not here: compiling the eight-wide
network a second time with AVX2 enabled (LLVM emits the same scalar code
either way -- the i64 butterfly products do not vectorise, so an
explicit vpmuldq kernel is the remaining lever), and an in-place
bit-reversal permute.
test(av1): pin Option<MiInfo> at 32 bytes or lessAhmet Kaan Gümüş · 4bb9310
test(av1): pin Option<MiInfo> at 32 bytes or less

The 4K mi grid is ~518k cells refilled per frame and walked by every mv-stack
scan, so a widened field here is a measurable throughput regression rather
than a free change.
perf(av1): coefficient reading -- buffered msac bit window, static scan tables, no per-block level allocationAhmet Kaan Gümüş · 8841aa8
perf(av1): coefficient reading -- buffered msac bit window, static scan tables, no per-block level allocation

The frame thread's coefficient path paid four avoidable costs per transform
block, all bit-exact to remove:

* every symbol's renormalisation assembled five bytes out of the payload and
  shifted twice; `SymbolDecoder` now keeps a 64-bit window refilled once per
  eight bytes (`bulk_bit_reads_match_the_per_bit_form` still pins `f(n)`
  against the per-bit form, through the new `seek_bits`);
* `symbol_fixed`/`symbol`/`f`/`update_cdf` were out-of-line across codegen
  units, and the CDF walk indexed a slice the bounds checker could not see
  the end of -- inlined, and the walk iterates instead;
* `default_scan` allocated a `Vec` and regenerated the whole anti-diagonal
  walk on every block: one table per side (4/8/16/32), built once;
* `read_coeffs` divided by the transform side per coefficient (always a power
  of two) and allocated its level buffer per block.

instructions:u on the 4K segment at one thread: 570.76 G -> 559.11 G (-2.0%).
All 12 gate hashes unchanged at 1/4/16 threads; lib suite 500 passed, 27
ignored.
perf(av1): mi-grid writers fill whole rows and MiInfo carries u8 block sidesAhmet Kaan Gümüş · 77576dd
perf(av1): mi-grid writers fill whole rows and MiInfo carries u8 block sides

The mode-info bookkeeping the parse thread runs per coded block wrote its
grids one 4x4 cell at a time, each write a bounds check: `fill_lf_grid_rect`
(6 grids), `fill_skip_grid_rect` (4), `record_uv_mode_mi`, `record_mi_rect`
and `record_inter_rect_mi`. A mi rect's cells are contiguous inside one grid
row, so each of those rows is one `fill_span` -- same cells, same values,
including the out-of-range drop the per-cell `get_mut`/`break` did.

`record_mi_rect`'s per-cell `array::from_fn` predicate is monotone in the
plane bound (`bound[1] == bound[2] >= bound[0]`), so the left/above neighbour
state is three contiguous runs, not a branch per cell.

`MiInfo::size`/`size_h` are 4x4-cell counts that never exceed 32; as `u8`
they take `Option<MiInfo>` from 48 to 28 bytes, shrinking both the per-frame
grid fill and the mv-stack scans' cache footprint.

Byte-exact: all 12 gate hashes unchanged. instructions:u on the 4K segment
570.74 G -> 565.02 G (-1.00%).
perf(av1): the output crop and the post-deblock snapshot stop copying whole planesAhmet Kaan Gümüş · 36f0c53
perf(av1): the output crop and the post-deblock snapshot stop copying whole planes

Two bulk copies on the frame thread's serial tail, both of them avoidable:

* The output crop rebuilt every plane row by row whenever the padded
  coding surface was bigger than the visible frame. A 4K 3840x1608 frame
  is superblock-aligned in WIDTH and padded only in HEIGHT, so its padded
  buffer's stride already equals the visible width and the "crop" is a
  pure truncation of the buffer we already own. `crop_owned` takes the
  plane by value and truncates in that case, falling back to the old
  row-by-row copy for a genuinely narrower plane.

* The post-deblock snapshot loop restoration reads cloned all three
  planes. Spec 7.17.2's stripe boundary substitution only ever reads the
  two rows above and the two below each interior stripe boundary
  (`restoration::lr_src_row` resolves every out-of-stripe row to
  `stripe_v_start-1/-2` or `stripe_v_end/+1`), and stripes are
  `64 >> ss_y` rows offset by `RESTORATION_UNIT_OFFSET`, so the snapshot
  now copies 4 rows in 64 into a pooled buffer whose other rows keep a
  previous frame's samples -- initialised values no reader reaches.

Byte-exact: seg1080/seg4k/seg4k_lr/palette hashes unchanged at 1, 4 and
16 frame threads (the last with 4 filter + 2 recon threads).