Commits
Commits on
e08e4e454bdf7b9c0454d2f9aaa8f08674823b912026-09-05
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.
Merge branch 'lane-deblock2' (8587f4c7): deblock kernel monomorphised on edge length with a mask early-out, EdgeCtx replaces seven per-pass args, filter level tabulated per band over (base level, ref frame); byte-exact, -0.74% instructions on the 4K segmentAhmet Kaan Gümüş · 6d124e3Browse files
Merge branch 'lane-cdef' (29dfc7d8): CDEF direction search row-at-a-time with an AVX2 partials twin, i16 gather window tapped in place by the filter kernel; byte-exact, -1.1% instructions on the 4K segmentAhmet Kaan Gümüş · d35cd3aBrowse files
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.
Merge branch 'lane-tx2' (c084630a): explicit AVX2 Lane impl for the inverse-DCT column pass (exact i64 products, full-range equivalence test; target_feature on the leaf methods), all-zero transform units carry an empty residual marker instead of allocating and cloning zero grids; byte-exact, -4.0% instructions on the 4K segmentAhmet Kaan Gümüş · 140e662Browse files
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.
Merge branch 'lane-mc' (9a1ae95e): MC intermediate narrowed to i16 (range proven from the filter tables at 8/10-bit, pinned by test), vertical pass on madd_epi16 row pairs with round+clamp+narrow fused, constant-length whole-pel copies; wiener shares the kernels and stays exact; byte-exact, -5.5% instructions on the 4K segmentAhmet Kaan Gümüş · e27b2d5Browse files
Merge branch 'lane-deblock' (64791ded): deblock edge_params split into an inlined alignment gate + out-of-line body, power-of-two mask instead of a divide, AVX2 filter14 as a running sum over constant weight deltas; byte-exact, -3.6% instructions on the 4K segmentAhmet Kaan Gümüş · 74e98d8Browse files
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.
Merge branch 'lane-tx' (07c71e86): inverse DCT monomorphised per size, eight-wide column pass through a Lane trait, all-zero transform grids skipped (60% of 4K transform units); byte-exact, -5.2% instructions on the 4K segmentAhmet Kaan Gümüş · d60c70eBrowse files
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.
Merge branch 'lane-mi' (7b15f443): mode-info grids filled per contiguous row span instead of per 4x4 cell, MiInfo size fields u8 (Option<MiInfo> 48 -> 28 bytes), record_mi_rect neighbour state as three contiguous runs; byte-exact, -1.0% instructions on the 4K segmentAhmet Kaan Gümüş · 46b0c49Browse files
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.
Merge branch 'lane-coef' (d1f7fca6): msac 64-bit refill window + inlined symbol reads, static default_scan tables (was a Vec regenerated per transform block), stack level buffer in read_coeffs; byte-exact, -2.0% instructions on the 4K segmentAhmet Kaan Gümüş · 1e1c40eBrowse files
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%).
Merge branch 'lane-copy' (2bbf188c): output crop is a truncation of the owned padded buffer when the width is SB-aligned; LR deblocked snapshot copies only the 4 rows per stripe boundary it can read; byte-exact. Also: grain row wrappers kept for the kernel-vs-scalar tests are cfg(test) (4 dead_code warnings from ab320fac)Ahmet Kaan Gümüş · 5a5f194Browse files
Merge branch 'lane-alloc' (ac8f45db): per-block allocation cut (debug format! strings behind env flags, intra Edges 4 vecs -> 2, OBMC neighbour buffer caller-held, mv stacks reserve their cap) + alloc_probe tracking-allocator instrument; byte-exact, -0.39% instructions on the 4K segmentAhmet Kaan Gümüş · 95d7cebBrowse files
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).
Merge branch 'lane-grain' (643c1001): film grain noise kernels take the whole block (row loop inside, 4-wide tail step) -- per-row AVX2 on 15-wide chroma blocks paid the prologue per row and sent half the samples to the scalar tail; byte-exact, -2.7% instructions on the 4K segmentAhmet Kaan Gümüş · 9346288Browse files
perf(av1): remove four per-block allocation sites from the parse pathAhmet Kaan Gümüş · d4c852e
perf(av1): remove four per-block allocation sites from the parse path
lane-alloc. A tracking global allocator (new `alloc_probe` example: size
histogram plus a sampled backtrace per 512 allocations, with line numbers)
ranked the decoder's allocation sites on the 4K segment -- 83.6 M
allocations over 272 frames. Four of the top sites are removed here:
* `find_samples` built a `String` per warp block (`format!("{mi_row},
{mi_col}")` plus the env snapshot's own `String` clone) to compare against
an unset debug flag; the OBMC blend did the same for `EC_MCB`. Both now
sit behind the per-call-site `env_flag!` load.
* `Edges::build` allocated four vectors per intra prediction (collect,
grow, then a second buffer to prepend the corner); it builds each edge
once, corner first. `directional`'s two working buffers were a copy of
those same vectors, so it takes the `Edges` by value instead.
* `obmc_neighbour_pred` allocated its prediction buffer per neighbour per
plane; the caller now keeps one buffer per plane for the whole block.
* The MV stacks and the OBMC neighbour lists are capped (8 entries /
`max_neighbors`), so they reserve once rather than growing and memcpying
up to four times.
seg4k at one thread: 601.657 -> 599.329 G instructions:u (-0.39%, perf stat
-r 3). Reverting only the reserve step measured 600.014 G, so it stays
despite raising the raw allocation COUNT (an empty stack now allocates):
the saved reallocation memcpys outweigh the extra tcache hits.
Byte-exact: sha6t hashes equal the reference for all four streams at
threads 1, 4 and 16 (the last with FILTER_THREADS=4 RECON_THREADS=2).Merge branch 'lane-sgr' (55600639): sgrproj compute_ab box sums over a contiguous edge-replicated row in i32, (A,B) map as an AVX2 row pass; byte-exact, -0.86% instructions on the LR segmentAhmet Kaan Gümüş · 184abb3Browse files
perf(av1): film grain noise rows take the whole block in one AVX2 callAhmet Kaan Gümüş · 4786458
perf(av1): film grain noise rows take the whole block in one AVX2 call The 32x32 grain block is 30 luma / 15 chroma samples wide once the 2-column overlap is cut off, so the per-row AVX2 kernels paid their 10-broadcast prologue once per row and handed the `30 % 8 == 6` / `15 % 8 == 7` remainder to the scalar loop -- half of every chroma row. That is why `chroma_noise_row_scalar` outweighed the AVX2 kernel it was supposed to be the fallback of. The row loop moves inside the kernels (`luma_noise_rows` / `chroma_noise_rows`, strides and a row count), so the prologue is paid once per block, and the remainder takes a 4-wide SSE step before the at most 3 scalar samples. The row-level entry points stay as thin wrappers for the tests that pin them against the scalar reference. seg4k at one thread: 601.754 G -> 585.462 G instructions:u (-2.7% of the whole decode, a quarter of film grain's 65 G). Byte-exact: all four gate hashes unchanged at 1 and 4 threads.
perf(av1): sgrproj box sums in i32 over a contiguous row, (A,B) map under AVX2Ahmet Kaan Gümüş · 9c6f09f
perf(av1): sgrproj box sums in i32 over a contiguous row, (A,B) map under AVX2 `compute_ab` fetched every window sample through `lr_sample` -- a stripe-boundary decision plus a column clamp per element -- and carried both box sums as `i64`. A sample is at most `2^bd - 1 <= 4095`, so the widest window sum of squares is `25 * 4095^2 == 419M`: the sums fit `i32` with room to spare, and the column clamp is a pure function of the column, so one contiguous per-row copy with the plane edge replicated serves the whole accumulate pass branch-free. On top of that the per-grid-point `(A[k], B[k])` map -- the part a previous lane measured as the real cost -- becomes a straight-line pass over two row arrays, so it runs eight points at a time under AVX2: lane-wise the same arithmetic, with the only two products that exceed 32 bits (`p * s` and `(256 - A) * one_by_x * b`) formed in 64-bit even/odd halves and packed back after their rounding shift, and `av1_x_by_xplus1` read by gather. `ab_point` stays the scalar reference for the tail and for every non-AVX2 target. Byte-exact: all four gate streams hash identically to the parent at 1 and 4 threads. instructions:u on the 4K restoration segment 602.650 G -> 597.501 G (-0.86%; -0.29% from the sums, -0.57% from the AVX2 map).
Merge branch 'lane-wave5' (83a87ee2): reconstruction wavefront takes jobs from per-superblock-row queues (one raster FIFO had serialised workers on one row); EC_AV1_WAVE_STATS instrument; byte-exact at all settings; 4K 32.1 fps at (16,4,2), 1080p 75 fpsAhmet Kaan Gümüş · 8cdbcf4Browse files
perf(av1): recon workers pick per superblock ROW, not raster orderAhmet Kaan Gümüş · bdf81cd
perf(av1): recon workers pick per superblock ROW, not raster order At EC_AV1_RECON_THREADS > 1 the wavefront handed out jobs from one FIFO in raster order, so N workers popped N CONSECUTIVE superblocks of the SAME row -- which the wavefront rule serialises (a job waits on its own left neighbour). The workers then all blocked on one dependency chain and the tile ran near-serial: 4 workers, 155% CPU, 1.23x. The queue is now per superblock row and a worker takes the lowest row whose front job's dependencies are met, which is the only job of that row that can be runnable; deadlock-freedom is unchanged (the globally oldest job is always runnable once no worker is active). EC_AV1_WAVE_STATS=1 dumps the per-worker busy/wait/jobs accounting, the parse-thread time between submits and the barrier/drain waits, cumulatively, on every tile. seg4k (frame,filter,recon)=(1,1,4): 24.43 s -> 22.90 s, the parse-side barrier wait 1917 ms -> 123 ms over the same 6712 barriers. All 12 sha6t hashes exact at (1,1,1), (1,1,4) and (16,2,2).
Merge branch 'lane-t900' (196962d8): worker threads named by class (frame/recon/filter), dead wavefront helpers deleted, last warning cleared; byte-exactAhmet Kaan Gümüş · f37b756Browse files
refactor(av1): name the pool worker threads by submitting class; drop two dead recordersAhmet Kaan Gümüş · 9a4d798
refactor(av1): name the pool worker threads by submitting class; drop two dead recorders The persistent pool is thread-local and shared by every class a thread submits, so a worker's name is the class that grew the pool for it: `ec-av1-frame` (stream.rs), `ec-av1-recon` (the tile wavefront) and `ec-av1-filter` (par::run_bands), plus its index. The test-only ffmpeg and aomenc stdin writers in decode.rs/stream.rs get names too. Also deletes `push_intra_owned`/`push_mc_rect_owned`, dead since the wavefront lanes, and replaces a `drop` of a `Copy` `Shared` in film_grain.rs with `let _ =`, which was the last ec-av1 warning. Byte-exact: the four perf6 inputs hash unchanged at default and at (6,2,4) threads.
Merge branch 'lane-pool1' (3362287c): persistent per-thread worker pools replace per-frame and per-tile thread spawns; DPB slots, reorder queue and outputs carry Arc<Picture> instead of copies; byte-exact at every thread setting on four inputs; 4K reaches real time from 12 frame threads (16,2,2 = 27.5 fps)Ahmet Kaan Gümüş · 2504addBrowse files
perf(av1): the reference bank and the output queue share the pictureAhmet Kaan Gümüş · 900cf2d
perf(av1): the reference bank and the output queue share the picture A decoded frame's picture was copied once per reference slot it refreshes and once more to leave the worker (`Arc::try_unwrap` never succeeded -- the slot promise holds the other handle), 24 MB per copy at 4K 10-bit. `ref_slots`, `Reorder` and the worker reply now carry `Arc<Picture>`: the sink still takes `&Picture`, so no public signature moves, and grain (which must not be stored in the bank) still allocates its own output. seg4k, all 12 sha6t hashes unchanged at (1,1,1), (6,2,4), (1,1,4). Single thread: 30.39 s -> 29.71 s, page faults 397 k -> 111 k, instructions:u 599.40 -> 600.57 G (+0.20%). Composed (6,2,4) best-of-2 interleaved: 12.58 s base -> 12.08 s, page faults 3.77 M -> 0.85 M.
perf(av1): persistent worker pools instead of per-frame and per-tile threadsAhmet Kaan Gümüş · a02c7bd
perf(av1): persistent worker pools instead of per-frame and per-tile threads Every threaded stage spawned its threads per unit of work: one `thread::scope` per filter stage per frame, `EC_AV1_RECON_THREADS` workers per tile, one frame worker per coded frame -- 2363 distinct threads in a 13 s 4K decode. What died with each of them was the `thread_local!` decode scratch (planes, rows, dq, mc, wiener, sgr), re-allocated and re-faulted on every new thread. `par::Batch` submits jobs to a pool owned by the submitting thread (thread-local, joined at thread exit), growing to `busy + queued` so a job never queues behind a blocking one -- the recon wavefront's workers block on their own dependencies. `Batch`'s drop waits every job out and re-raises the first panic, which is `thread::scope`'s contract minus the spawns, so the three call sites keep their borrows. Byte-exact: all 12 sha6t hashes at (frame, filter, recon) = (1,1,1), (6,2,4) and (1,1,4). seg4k (6,2,4) best-of-2 interleaved: 13.02 s -> 12.24 s.
Merge branch 'lane-wave1' (4c9f7f81): inter prediction of both decode_inter_block arms deferred to the reconstruction worker as a closure op; interintra blend on the worker; byte-exact at recon 1, 4 and the composed setting; 11% faster at recon-only settings, neutral at the composed bestAhmet Kaan Gümüş · 33312b9Browse files
perf(av1): a deferred transform unit takes its window on the worker, not a strided residualAhmet Kaan Gümüş · 3d6af60
perf(av1): a deferred transform unit takes its window on the worker, not a strided residual lane-wave4: recording a unit's prediction as an offset into the block made the worker lay its residual out at the block's stride again (a 4x4 unit of a 64-wide block meant a 64x64 i32 grid). The residual stays dense and the worker copies the w x h window out of the block prediction instead -- the copy the parsing thread used to make. Byte-exact, wall unchanged.
perf(av1): a compound inter block predicts on the worker tooAhmet Kaan Gümüş · 52da7db
perf(av1): a compound inter block predicts on the worker too lane-wave4: the compound arm's whole prediction -- both references, the wedge/diffwtd/distance blend, all three planes -- becomes the same deferred closure the single-reference arm got. A compound block reads neither motion_mode nor interintra, so its build has nothing that must stay on the parsing thread.
perf(av1): a single-reference inter block predicts on the worker that reconstructs itAhmet Kaan Gümüş · 4a7d65a
perf(av1): a single-reference inter block predicts on the worker that reconstructs it lane-wave4: the whole-block prediction of `decode_inter_block`'s single-reference arm (motion compensation + warp + the interintra blend) is now a closure instead of a buffer. At one reconstruction thread the parse thread runs it at the same point as before; at EC_AV1_RECON_THREADS > 1 it is pushed as a `ReconOp::Pred` and runs on the wavefront worker, whose transform units then read their windows out of it -- so mc no longer runs on the parsing thread there. The interintra blend goes with it, which retires that arm's `flush_recon` barrier: the wavefront rule already guarantees the block's own edges. OBMC and the sub-8x8 chroma piece still build inline (both can fail, and a recorded op cannot report it). Also fixes the inline path stage 1 broke: a window handed over at the block's stride was reconstructed against a dense residual.
refactor(av1): a recorded inter write names where its prediction comes fromAhmet Kaan Gümüş · 8aa7db1
refactor(av1): a recorded inter write names where its prediction comes from lane-wave4 step 1: `ReconOp::Mc` carries a `PredSrc` (an owned window, or an offset into the block prediction a worker builds) and the inter readers take a `Pred` instead of a slice, so a prediction can be deferred without touching every call site again. No deferral yet: every site passes `Pred::dense`, which is the same window copy as before.
Merge branch 'lane-wave1' (22e1ab44): dequantisation and inverse transform run on the reconstruction workers from recorded coefficients; Mc ops carry only their transform-unit window; byte-exact at recon 1, 4 and the composed setting; 4K 21.3 fps at (6,2,4)Ahmet Kaan Gümüş · 11ef8caBrowse files
Merge branch 'lane-perf11' (2f7fcb64): CDEF band body as a real function with reference parameters (alias facts restored); byte-exact at 1 and 4 filter threads, 0.9% fewer instructions at 4KAhmet Kaan Gümüş · f97a50bBrowse files
perf(av1): a recorded inter write carries its own transform unit, not the blockAhmet Kaan Gümüş · 89f1aa3
perf(av1): a recorded inter write carries its own transform unit, not the block reconstruct_mc_rect reads exactly rows 0..h and columns 0..w of the two buffers, so recording the whole block prediction copied 64*64 samples on the parsing thread for a 4x4 unit. The record now holds that window densely at stride w, and the deferred residual is produced dense to match (TxParams::stride = 0) -- the same numbers in the same places. Byte-exact at recon 4 on all four probe inputs.
perf(av1): the inverse transform travels with the recorded write, not its resultAhmet Kaan Gümüş · c027c27
perf(av1): the inverse transform travels with the recorded write, not its result
A recorded reconstruction carried the already-transformed residual, so the
parsing thread ran the dequantization and the inverse transform for every
transform unit before a recon worker ever saw it. The three fused
coefficient readers now record TxParams + the coded grid instead
(ReconOp::{Intra,Mc}.residual is a Residual: Done or Coeffs), and
TxParams::run is the single copy of the produce-the-residual code both
paths call -- so at EC_AV1_RECON_THREADS=1 it still runs at the push site,
unchanged, and above 1 it runs on the worker.
Byte-exact at recon 1 and 4 on all four probe inputs (seg1080 c2d4ef66,
seg4k 3ac25ee5, seg4k_lr d197dbe0, palette 2bfb6839).Merge branch 'lane-wave1' (384ed8e6): reconstruction recorded as replayable ops with an inline fast path at one recon thread; superblock-row wavefront workers behind EC_AV1_RECON_THREADS (default 1, measured no gain yet: parse still builds predictions); byte-exact at all thread settings, default path 0.6% fewer instructionsAhmet Kaan Gümüş · 34a3d01Browse files
test(av1): the direct-call NEARMV gate replays its own recorded writesAhmet Kaan Gümüş · c28f320
test(av1): the direct-call NEARMV gate replays its own recorded writes Left red by step (i) (ace5dcb9), which this lane inherited: the gate calls the inter block decoder itself and reads the luma plane back, but a direct caller records its writes now -- only the tile decoder replays them -- so it compared an untouched plane against the reference prediction. It is the one test in `ec-av1 --lib` in that shape (499 passed, this one failed).
perf(av1): reconstruction on a superblock-row wavefront (EC_AV1_RECON_THREADS)Ahmet Kaan Gümüş · f7306dd
perf(av1): reconstruction on a superblock-row wavefront (EC_AV1_RECON_THREADS) lane-wave1 step (ii). Above one reconstruction thread the parser keeps parsing and never writes the planes: each superblock's drained `Vec<ReconOp>` becomes one job (one per 128x128 superblock when `sb128`, since a 128 block writes across its four 64x64 visits), and N scoped-per- tile workers reconstruct them in wavefront order -- job `(r, c)` starts once `(r - 1, min(c + 1, last_col))` and `(r, c - 1)` are complete, which covers every pixel an intra predictor can reach and every CfL AC read. Jobs are handed out in raster order, so the oldest outstanding one always has its dependencies met; a `WaveGuard` joins every worker on each exit from the tile decoder, including the `?` ones. The two parse-time pixel READS (the intrabc source fetch, the interintra intra predictor) keep their `flush_recon`, which now waits the wavefront out first and replays the current superblock inline -- so an intrabc block serialises the tile at that point instead of trusting the spec's 256-px delay against our lag, and stays byte-exact. MEASURED and it does not pay: seg4k 31.8 s at (frame, filter, recon) = (1,1,1) vs 31.9 s at (1,1,4) with CPU 99% -> 117%, seg1080 9.4 -> 9.9 s; with frame threading it is a loss (seg4k 13.5 s at (6,2,1) vs 14.5 s at (6,2,4)). Recording the ops copies the residual and the MC prediction on the PARSE thread, which cancels what the workers take off it. Default stays 1 (inline), where nothing is recorded at all. Byte-exact: sha6 on seg1080/seg4k/seg4k_lr/palette at recon 1, at recon 4, and at EC_AV1_THREADS=6 EC_AV1_FILTER_THREADS=2 EC_AV1_RECON_THREADS=4; new gate `a_real_stream_reconstructs_identically_with_one_and_four_recon_threads` on reelb_arf_witness (hidden ARF, 10-bit) and both palette/intrabc screen witnesses.
perf(av1): CDEF band body as a real function, so its plane writes are noaliasAhmet Kaan Gümüş · 065f637
perf(av1): CDEF band body as a real function, so its plane writes are noalias The CDEF row band ran as the body of the `run_bands` closure, where the three destination planes are `&mut PlaneBuf` derived from a `par::Shared` raw pointer in the same scope as the `src_*` pre-CDEF snapshot reads. LLVM cannot tell those apart, so every tap re-loaded plane fields and snapshot samples it had just read. Lifting the band into `cdef_band`, whose planes and snapshots arrive as distinct reference parameters, restores the alias facts; the strength lookup moves in with it (the grid arrives as `&[u8]`). Pure restructuring -- same walk, same order, same arithmetic. seg4k instructions:u 607.187 G -> 601.987 G (-0.86%), wall median of 3 30.50 s -> 30.27 s; seg1080 189.813 G -> 189.790 G, wall 9.23 s -> 9.28 s (noise). Byte-exact: all four gate streams hash identically at EC_AV1_FILTER_THREADS=1 and =4.