From 591f575f30e17e983a21852658474d6fd242ca5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Mon, 7 Sep 2026 04:45:45 +0300 Subject: [PATCH] perf(av1): measure the encoder's first decode -- 94% of it is parse, not reconstruction The encoder decodes its own written tiles once per frame to reach the reconstruction and the per-mi neighbour state the filter search reads (`par::S_FIRST`). The plan for removing it was to hand the decoder the encoder's own reconstruction, which the writer already holds. `EC_AV1_NORECON=1` drops every recorded pixel write in `exec_op` and leaves the entropy parse and the neighbour bookkeeping alone. At 3840x1608 (4 frames, 4x2 tiles, 8 tile threads) the stage moves 150 ms -> 141 ms: the reconstruction is 6% of it, the parse and the per-mi grids are the other 94%. So the planes are not the lever -- only a writer-side publisher of the filter-relevant `decode::Neighbours` grids (blk_grid, tx/tx_h, uv_tx/uv_tx_h, ref_grid, delta_lf_grid), which skips the parse entirely, can remove the stage. Measurement only; the flag is off by default and the encoder's own streams are byte-identical to their pins. --- crates/ec-av1/src/decode.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/ec-av1/src/decode.rs b/crates/ec-av1/src/decode.rs index 60aebffa..a1532214 100644 --- a/crates/ec-av1/src/decode.rs +++ b/crates/ec-av1/src/decode.rs @@ -3245,6 +3245,20 @@ fn exec_op( preds: &[u16], fctx: &crate::decode::FrameCtx, ) { + // lane-nbpub instrument: `EC_AV1_NORECON=1` drops every recorded pixel + // write, leaving the entropy parse and the per-mi neighbour bookkeeping + // alone. It makes the encoder's own streams garbage, so it is a + // MEASUREMENT rung only -- what it measures is how much of the encoder's + // first decode of its own tiles (`par::S_FIRST`) is reconstruction and + // how much is parse. Answer at 3840x1608 (4 frames, 4x2 tiles, 8 tile + // threads): 150 ms -> 141 ms, i.e. the reconstruction is 6% of that + // stage and the parse plus the neighbour grids are the other 94%. That + // is why handing the decoder the encoder's own reconstruction cannot + // shrink the stage: only publishing the per-mi neighbour state the + // filters read (and so never parsing at all) can. + if crate::envflags::env_flag!("EC_AV1_NORECON") { + return; + } let mut scratch = Vec::new(); match op { ReconOp::Pred(b) => (b.0)(y, u, v, fctx, cur),