From 30b0391cfe4f27b5574b64afa537cc8dee06480a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 6 Sep 2026 01:40:51 +0300 Subject: [PATCH] perf(av1): two-stage publication on by default With the sub-8x8 group predictions deferred, no parse thread reads a reference pixel at all (instrumented: zero `ref_planes` calls on the decode threads over both gate segments at 16 threads / 4 filter / 2 recon), so a consumer frame parses its WHOLE tile over its producer's filter tail instead of the 4.2% that made this flag a wash before. 4K critical chain, interleaved pairs at (16,4,2): off 14450 / 10594 / 14407 ms vs on 12790 / 9207 / 12463 ms -- 11-14% shorter, three pairs out of three, with wall agreeing (15.74/11.35/15.69 s vs 13.93/10.76/13.92 s). The same interleaving on the pre-lane-sub8group binary moves 3-7%, so most of the margin is the deferral. `EC_AV1_TWO_STAGE=0` restores the old publication point. Byte-exact: the four gate streams at 1, 4, 16(4,2) and 16(3,1) threads with the new default and at 16(4,2) with the flag forced off, plus six film cuts base vs new at 16(4,2). --- crates/ec-av1/src/stream.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index 35aa354c..d2e9b4e9 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -1006,18 +1006,17 @@ pub fn decode_stream_with_threads( decode_idx, shown_idx, dump.as_deref(), - // lane-twostage is OFF by default: it is byte-exact - // and the chain shows the producer tail overlapped, - // but it does not move the wall (the consumer parses - // only 4.2% of its tile before its first reference - // pixel read, which is shorter than the tail it - // hides). `EC_AV1_TWO_STAGE=1` publishes a frame's - // meta at its tile boundary instead of after its - // filters; it pays only once the 8x8-leaf, OBMC and - // sub-8x8-piece predictions are deferred to the recon - // workers as well. - crate::envflags::var("EC_AV1_TWO_STAGE") - .is_ok_and(|v| v == "1") + // lane-twostage publishes a frame's meta at its tile + // boundary instead of after its filters, so a consumer + // parses over its producer's filter tail. It is ON by + // default since lane-sub8group: with every reference + // pixel read deferred to the recon workers, the + // consumer parses its WHOLE tile before it needs a + // pixel, and the 4K critical chain shortens by 11-14% + // in three interleaved pairs (14450/10594/14407 ms off + // vs 12790/9207/12463 ms on) where it moved 3-7% + // before. `EC_AV1_TWO_STAGE=0` turns it back off. + (crate::envflags::var("EC_AV1_TWO_STAGE").as_deref() != Ok("0")) .then_some(&stage1 as &dyn Fn(_, _, _, _)), )?; // Publish before grain synthesis: every frame waiting on