From 347128937d6f03aa2d234e4132c2fef92f2c28f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 10 Sep 2026 02:27:22 +0300 Subject: [PATCH] feat(av1): the top ARF tpl window ships 11 pictures at preset 0 The split's budget was swept apart from TPL_D. WIN=11 at half=2 is film B +70.4/-2.2 against the split arm's +71.0/-1.8, film A flat; 11 saturates the one-group lookahead. Presets 3..=6 keep depth-1. Report closes the lane Claude died in. --- crates/ec-av1/src/speed.rs | 34 ++++++++++----- lanes/tplhalf.report.md | 87 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+), 10 deletions(-) create mode 100644 lanes/tplhalf.report.md diff --git a/crates/ec-av1/src/speed.rs b/crates/ec-av1/src/speed.rs index 86e4a06f..b4bf6f68 100644 --- a/crates/ec-av1/src/speed.rs +++ b/crates/ec-av1/src/speed.rs @@ -180,7 +180,6 @@ //! preset 3 BELOW preset 0 in every pass at load 16-25. The single-thread fps //! column above comes from the BD arms themselves and is ordered correctly. - use std::sync::atomic::{AtomicU8, Ordering}; /// The highest preset. 10 is the fastest, as in rav1e. @@ -537,11 +536,23 @@ pub(crate) const TPL_FUT_HALF: [usize; 11] = [2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1]; /// lane-tplhalf: how many entries mode 2's window holds in TOTAL, `0` meaning /// `encode::tpl_depth() - 1` (the budget every other tpl path uses). -/// `EC_AV1_TPL_FUT_WIN=` overrides it. It exists because the winning split -/// takes its whole future side from the budget's edge, so the budget had to -/// be tested apart from it (class `instrument at bound`) -- and apart from -/// `EC_AV1_TPL_D`, which deepens EVERY frame's lambda pass, not the ARF's. -pub(crate) const TPL_FUT_WIN: [usize; 11] = [0; 11]; +/// `EC_AV1_TPL_FUT_WIN=` overrides it. The winning split takes its whole +/// future side from the budget's edge, so the budget was swept apart from +/// it (class `instrument at bound`) and apart from `EC_AV1_TPL_D`, which +/// deepens EVERY frame's lambda pass. 48-picture long-GOP, half=2: +/// +/// | window | film A | film B | +/// |---|---|---| +/// | 7 (`tpl_depth-1`, the split's own arm) | +20.9/-9.0 | +71.0/-1.8 | +/// | 9 | +21.0/-9.0 | +70.7/-2.0 | +/// | **11 (ships at presets 0..=2)** | **+20.9/-9.0** | **+70.4/-2.2** | +/// +/// 11 is film B -0.6/-0.4 against 7 with film A flat -- the keep rule -- and +/// saturates the one-group lookahead (2 past + 8 future available). Presets +/// 3..=6 keep 0 (`depth-1` = 3 at `TPL_DEPTH=4`), unswept. `TPL_D=10` at +/// half=2 was byte-identical to WIN=9: extra depth on non-ARF frames is +/// unused because a pyramid leaf's window is the group's own successors. +pub(crate) const TPL_FUT_WIN: [usize; 11] = [11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0]; /// lane-arfpred: the qindex below which the ARF temporal filter is OFF -- /// libaom scales `arnr` strength with the quantizer and stops filtering at @@ -833,8 +844,7 @@ pub(crate) const RESTORATION: [bool; 11] = [ /// (`presets_are_monotone_in_speed`) forbids them going below preset 3's 4 /// in any case. /// * **presets 7..10 stay at 1**, unmeasured: not swept by this lane. -pub(crate) const TPL_DEPTH: [usize; 11] = - [crate::encode::TPL_DEPTH, 8, 8, 4, 4, 4, 4, 1, 1, 1, 1]; +pub(crate) const TPL_DEPTH: [usize; 11] = [crate::encode::TPL_DEPTH, 8, 8, 4, 4, 4, 4, 1, 1, 1, 1]; /// `encode::tx_type_search`: whether an intra luma transform unit searches /// its own `tx_type` instead of coding `DCT_DCT` (lane-txset). The five-type @@ -1016,12 +1026,16 @@ static KNOBS: std::sync::RwLock<()> = std::sync::RwLock::new(()); #[cfg(test)] #[must_use] pub(crate) fn knob_read() -> std::sync::RwLockReadGuard<'static, ()> { - KNOBS.read().unwrap_or_else(std::sync::PoisonError::into_inner) + KNOBS + .read() + .unwrap_or_else(std::sync::PoisonError::into_inner) } /// Held by a test that SETS a process-global knob; see [`KNOBS`]. #[cfg(test)] #[must_use] pub(crate) fn knob_write() -> std::sync::RwLockWriteGuard<'static, ()> { - KNOBS.write().unwrap_or_else(std::sync::PoisonError::into_inner) + KNOBS + .write() + .unwrap_or_else(std::sync::PoisonError::into_inner) } diff --git a/lanes/tplhalf.report.md b/lanes/tplhalf.report.md new file mode 100644 index 00000000..2840500c --- /dev/null +++ b/lanes/tplhalf.report.md @@ -0,0 +1,87 @@ +# lane-tplhalf: the top ARF's tpl split, then its budget + +Claude Code died mid-lane after the split commit (`0c8d5778`) and after +the WIN sweep logs landed; this report closes that lane. + +## 1. Premise + +`TPL_FUT=2` (lane-tplfut) concatenates past then future, nearest-first. +The split was `(tpl_depth()-1)/2` = 3 past + 4 future at depth 8, unswept. +The future half is taken from the budget's edge, so the budget itself had +to be swept apart from `EC_AV1_TPL_D` (which deepens every frame's lambda +pass, not the ARF window). Class: instrument-at-bound. + +## 2. Split sweep (`EC_AV1_TPL_FUT_HALF`) + +Deciding gate: `encode::tests::bd_rate_film_long_gop` (48 pictures), one +thread, native crops. BD vs libaom cpu-used 6 / rav1e speed 6, lower +better. Logs: `~/.cache/tplhalf/{control,h1,h2,h5}.log`. Load before each +arm 2.8-4.7, after 2.9-4.4. + +| past half | film A | film B | wall A | wall B | log | +|---|---|---|---|---|---| +| 1 (6 future) | +21.1 / -8.9 | +71.2 / -1.9 | 548.5s | 429.1s | h1.log | +| **2 (5 future, SHIPS)** | **+20.9 / -9.0** | **+71.0 / -1.8** | 551.3s | 442.3s | h2.log | +| 3 (4 future, old default) | +21.1 / -8.9 | +71.5 / -1.5 | 547.0s | 423.0s | control.log | +| 5 (2 future) | +21.1 / -8.9 | +71.5 / -1.6 | 561.8s | 438.6s | h5.log | + +Bracketed: 2 is down on all four columns against 3 (film A -0.2/-0.1, +film B -0.5/-0.3), and 1 and 5 are both worse than it on the deciding +film B libaom column. Wall of 2 is +0.8% / +4.6% vs 3, under the +15% +ceiling. `speed::TPL_FUT_HALF` = 2 at presets 0..=2; presets 3..=6 keep 1 +(`TPL_DEPTH=4`, unswept). + +## 3. Budget sweep (`EC_AV1_TPL_FUT_WIN`) at half=2 + +Same gate. `0` means `tpl_depth()-1` = 7. Logs: `h2.log`, `w9.log`, +`w11.log`, `h2d10.log`, `w11h3.log`. + +| window | film A | film B | wall A | wall B | log | +|---|---|---|---|---|---| +| 7 (`depth-1`) | +20.9 / -9.0 | +71.0 / -1.8 | 551.3s | 442.3s | h2.log | +| 9 | +21.0 / -9.0 | +70.7 / -2.0 | 545.3s | 430.2s | w9.log | +| **11 (SHIPS at presets 0..=2)** | **+20.9 / -9.0** | **+70.4 / -2.2** | 578.6s | 431.3s | w11.log | +| 11, half=3 (split re-check) | +20.9 / -9.0 | +70.9 / -1.9 | 554.8s | 437.7s | w11h3.log | +| `TPL_D=10` at half=2 | +21.0 / -9.0 | +70.7 / -2.0 | 543.7s | 435.8s | h2d10.log | + +11 vs 7: film B -0.6 / -0.4, film A 0.0 / 0.0 -- keep rule (one row +>=0.5 down, the other flat). Wall A +5.0%, wall B -2.5%. 11 saturates +the one-group lookahead (2 past + 8 future available). Half=3 at the +larger budget loses to half=2, so the split does not flip. + +`TPL_D=10` at half=2 is byte-identical to WIN=9 (same PSNR/bytes on both +films): extra depth on non-ARF frames is unused because a pyramid leaf's +window is the group's own successors. That is why WIN is its own knob. + +`speed::TPL_FUT_WIN` = 11 at presets 0..=2; presets 3..=6 keep 0 +(`depth-1` = 3 at `TPL_DEPTH=4`), unswept. + +## 4. 12-picture native guard + +STRUCTURALLY BLIND: `group_target` absorbs a 12-picture tail into one +group, so no next group is buffered and mode 2 falls back to the past +window. Not re-run; the standing table's 12-frame rows are the guard. + +## 5. Witness + +`encoder::tests::the_future_tpl_window_still_codes_every_picture_and_moves_the_stream` +already names that mode 2 at the old 3-past split is byte-identical on +the 128x128 fixture and that `EC_AV1_TPL_FUT_HALF=1` moves it. No new +witness: the long-GOP gate is the measurement. + +## 6. Other gates + +Recorded at merge time (this file's suite line). Pins are expected +unmoved: the 4-picture pin fixture has no next group, so the fallback +keeps the past window. + +## Deviations + +* Claude subscription died after the split commit and after the WIN + logs; this close is from those logs plus the WIN default they keep. +* Presets 3..=6 split and budget left unswept (named in the tables). +* 12-frame rows not re-measured (structurally blind, accepted). + +## Suite line + +Pending merge gates on this close.