forge
Explore
Log in

Don't you dare go Hollow

Merge branch 'lane-tplhalf' (600dfa34): the top ARF's temporal lambda split ships at 2 past neighbours and its window at 11 pictures; long-GOP film B +71.6/-1.5 to +70.4/-2.2; pins unmoved at 8291 / 33227

Browse files at this commit

87c6dbd321592759bc383a1b64c880e4caa7b4ebAhmet Kaan GümüşParent: bda62603471289
crates/ec-av1/src/encoder.rsmodified+28 -3
@@ -1298,6 +1298,31 @@ pub(crate) fn tpl_fut() -> usize {
1298 .unwrap_or_else(|| crate::speed::at(&crate::speed::TPL_FUT))1298 .unwrap_or_else(|| crate::speed::at(&crate::speed::TPL_FUT))
1299 }1299 }
1300 1300
1301+/// lane-tplhalf: mode 2's split -- how many display-PAST neighbours the top
1302+/// ARF's window opens with, the rest of the budget coming from the buffered
1303+/// future ([`crate::speed::TPL_FUT_HALF`], `EC_AV1_TPL_FUT_HALF=<n>`).
1304+pub(crate) fn tpl_fut_half() -> usize {
1305+ std::env::var("EC_AV1_TPL_FUT_HALF")
1306+ .ok()
1307+ .and_then(|v| v.parse().ok())
1308+ .unwrap_or_else(|| crate::speed::at(&crate::speed::TPL_FUT_HALF))
1309+}
1310+
1311+/// lane-tplhalf: how many entries mode 2's window holds in total, `0` meaning
1312+/// `tpl_depth() - 1` -- the ARF window's budget alone, so raising it does not
1313+/// deepen every other frame's lambda pass the way `EC_AV1_TPL_D` does
1314+/// ([`crate::speed::TPL_FUT_WIN`], `EC_AV1_TPL_FUT_WIN=<n>`).
1315+pub(crate) fn tpl_fut_win(depth: usize) -> usize {
1316+ match std::env::var("EC_AV1_TPL_FUT_WIN")
1317+ .ok()
1318+ .and_then(|v| v.parse().ok())
1319+ .unwrap_or_else(|| crate::speed::at(&crate::speed::TPL_FUT_WIN))
1320+ {
1321+ 0 => depth - 1,
1322+ n => n,
1323+ }
1324+}
1325+
1301 /// lane-lookahead: whether the pyramid path holds one group of lookahead1326 /// lane-lookahead: whether the pyramid path holds one group of lookahead
1302 /// ([`crate::speed::LOOKAHEAD`], `EC_AV1_LOOKAHEAD=0|1`).1327 /// ([`crate::speed::LOOKAHEAD`], `EC_AV1_LOOKAHEAD=0|1`).
1303 fn lookahead() -> bool {1328 fn lookahead() -> bool {
@@ -2253,10 +2278,10 @@ impl Av1Encoder {
2253 // the nearest past and the nearest future neighbour spans the2278 // the nearest past and the nearest future neighbour spans the
2254 // whole group), which is the arm's known cost.2279 // whole group), which is the arm's known cost.
2255 (2, _, _) => {2280 (2, _, _) => {
2256- let half = std::env::var("EC_AV1_TPL_FUT_HALF").ok().and_then(|v| v.parse().ok()).unwrap_or((depth - 1) / 2);2281+ let budget = tpl_fut_win(depth);
2257 let mut w = past();2282 let mut w = past();
2258- w.truncate(half.max(1));2283+ w.truncate(tpl_fut_half().max(1));
2259- let room = (depth - 1).saturating_sub(w.len());2284+ let room = budget.saturating_sub(w.len());
2260 w.extend(arf_tpl_future(room));2285 w.extend(arf_tpl_future(room));
2261 w2286 w
2262 }2287 }
crates/ec-av1/src/speed.rsmodified+47 -5
@@ -180,7 +180,6 @@
180 //! preset 3 BELOW preset 0 in every pass at load 16-25. The single-thread fps180 //! preset 3 BELOW preset 0 in every pass at load 16-25. The single-thread fps
181 //! column above comes from the BD arms themselves and is ordered correctly.181 //! column above comes from the BD arms themselves and is ordered correctly.
182 182
183-
184 use std::sync::atomic::{AtomicU8, Ordering};183 use std::sync::atomic::{AtomicU8, Ordering};
185 184
186 /// The highest preset. 10 is the fastest, as in rav1e.185 /// The highest preset. 10 is the fastest, as in rav1e.
@@ -515,6 +514,46 @@ pub(crate) const LOOKAHEAD: bool = true;
515 /// +-0.3) at +3.2% / +0.2% wall.514 /// +-0.3) at +3.2% / +0.2% wall.
516 pub(crate) const TPL_FUT: [usize; 11] = [2; 11];515 pub(crate) const TPL_FUT: [usize; 11] = [2; 11];
517 516
517+/// lane-tplhalf: mode 2's SPLIT -- how many display-PAST neighbours the top
518+/// ARF's window opens with; the rest of [`TPL_FUT_WIN`] comes from the
519+/// buffered future. `EC_AV1_TPL_FUT_HALF=<n>` overrides it, and the value is
520+/// clamped up to 1 (a zero past half is mode 1, refuted).
521+///
522+/// Swept on the 48-picture long-GOP gate at `TPL_DEPTH = 8` (budget 7),
523+/// BD-rate vs libaom / vs rav1e, lower better:
524+///
525+/// | past half | film A | film B | wall A | wall B |
526+/// |---|---|---|---|---|
527+/// | 1 (6 future) | +21.1/-8.9 | +71.2/-1.9 | 548.5s | 429.1s |
528+/// | **2 (5 future, ships)** | **+20.9/-9.0** | **+71.0/-1.8** | 551.3s | 442.3s |
529+/// | 3 (4 future, the old default) | +21.1/-8.9 | +71.5/-1.5 | 547.0s | 423.0s |
530+/// | 5 (2 future) | +21.1/-8.9 | +71.5/-1.6 | 561.8s | 438.6s |
531+///
532+/// Bracketed on both sides: 2 is down on all four columns against 3, and 1
533+/// and 5 are both worse than it. Presets 3..6 run `TPL_DEPTH = 4`, where the
534+/// old `(depth-1)/2` split was 1 -- left there, unswept.
535+pub(crate) const TPL_FUT_HALF: [usize; 11] = [2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1];
536+
537+/// lane-tplhalf: how many entries mode 2's window holds in TOTAL, `0` meaning
538+/// `encode::tpl_depth() - 1` (the budget every other tpl path uses).
539+/// `EC_AV1_TPL_FUT_WIN=<n>` overrides it. The winning split takes its whole
540+/// future side from the budget's edge, so the budget was swept apart from
541+/// it (class `instrument at bound`) and apart from `EC_AV1_TPL_D`, which
542+/// deepens EVERY frame's lambda pass. 48-picture long-GOP, half=2:
543+///
544+/// | window | film A | film B |
545+/// |---|---|---|
546+/// | 7 (`tpl_depth-1`, the split's own arm) | +20.9/-9.0 | +71.0/-1.8 |
547+/// | 9 | +21.0/-9.0 | +70.7/-2.0 |
548+/// | **11 (ships at presets 0..=2)** | **+20.9/-9.0** | **+70.4/-2.2** |
549+///
550+/// 11 is film B -0.6/-0.4 against 7 with film A flat -- the keep rule -- and
551+/// saturates the one-group lookahead (2 past + 8 future available). Presets
552+/// 3..=6 keep 0 (`depth-1` = 3 at `TPL_DEPTH=4`), unswept. `TPL_D=10` at
553+/// half=2 was byte-identical to WIN=9: extra depth on non-ARF frames is
554+/// unused because a pyramid leaf's window is the group's own successors.
555+pub(crate) const TPL_FUT_WIN: [usize; 11] = [11, 11, 11, 0, 0, 0, 0, 0, 0, 0, 0];
556+
518 /// lane-arfpred: the qindex below which the ARF temporal filter is OFF --557 /// lane-arfpred: the qindex below which the ARF temporal filter is OFF --
519 /// libaom scales `arnr` strength with the quantizer and stops filtering at558 /// libaom scales `arnr` strength with the quantizer and stops filtering at
520 /// the high-quality end for the same reason: a picture we are about to559 /// the high-quality end for the same reason: a picture we are about to
@@ -805,8 +844,7 @@ pub(crate) const RESTORATION: [bool; 11] = [
805 /// (`presets_are_monotone_in_speed`) forbids them going below preset 3's 4844 /// (`presets_are_monotone_in_speed`) forbids them going below preset 3's 4
806 /// in any case.845 /// in any case.
807 /// * **presets 7..10 stay at 1**, unmeasured: not swept by this lane.846 /// * **presets 7..10 stay at 1**, unmeasured: not swept by this lane.
808-pub(crate) const TPL_DEPTH: [usize; 11] =847+pub(crate) const TPL_DEPTH: [usize; 11] = [crate::encode::TPL_DEPTH, 8, 8, 4, 4, 4, 4, 1, 1, 1, 1];
809- [crate::encode::TPL_DEPTH, 8, 8, 4, 4, 4, 4, 1, 1, 1, 1];
810 848
811 /// `encode::tx_type_search`: whether an intra luma transform unit searches849 /// `encode::tx_type_search`: whether an intra luma transform unit searches
812 /// its own `tx_type` instead of coding `DCT_DCT` (lane-txset). The five-type850 /// its own `tx_type` instead of coding `DCT_DCT` (lane-txset). The five-type
@@ -988,12 +1026,16 @@ static KNOBS: std::sync::RwLock<()> = std::sync::RwLock::new(());
988 #[cfg(test)]1026 #[cfg(test)]
989 #[must_use]1027 #[must_use]
990 pub(crate) fn knob_read() -> std::sync::RwLockReadGuard<'static, ()> {1028 pub(crate) fn knob_read() -> std::sync::RwLockReadGuard<'static, ()> {
991- KNOBS.read().unwrap_or_else(std::sync::PoisonError::into_inner)1029+ KNOBS
1030+ .read()
1031+ .unwrap_or_else(std::sync::PoisonError::into_inner)
992 }1032 }
993 1033
994 /// Held by a test that SETS a process-global knob; see [`KNOBS`].1034 /// Held by a test that SETS a process-global knob; see [`KNOBS`].
995 #[cfg(test)]1035 #[cfg(test)]
996 #[must_use]1036 #[must_use]
997 pub(crate) fn knob_write() -> std::sync::RwLockWriteGuard<'static, ()> {1037 pub(crate) fn knob_write() -> std::sync::RwLockWriteGuard<'static, ()> {
998- KNOBS.write().unwrap_or_else(std::sync::PoisonError::into_inner)1038+ KNOBS
1039+ .write()
1040+ .unwrap_or_else(std::sync::PoisonError::into_inner)
999 }1041 }
lanes/tplhalf.report.mdadded+87 -0
@@ -0,0 +1,87 @@
1+# lane-tplhalf: the top ARF's tpl split, then its budget
2+
3+Claude Code died mid-lane after the split commit (`0c8d5778`) and after
4+the WIN sweep logs landed; this report closes that lane.
5+
6+## 1. Premise
7+
8+`TPL_FUT=2` (lane-tplfut) concatenates past then future, nearest-first.
9+The split was `(tpl_depth()-1)/2` = 3 past + 4 future at depth 8, unswept.
10+The future half is taken from the budget's edge, so the budget itself had
11+to be swept apart from `EC_AV1_TPL_D` (which deepens every frame's lambda
12+pass, not the ARF window). Class: instrument-at-bound.
13+
14+## 2. Split sweep (`EC_AV1_TPL_FUT_HALF`)
15+
16+Deciding gate: `encode::tests::bd_rate_film_long_gop` (48 pictures), one
17+thread, native crops. BD vs libaom cpu-used 6 / rav1e speed 6, lower
18+better. Logs: `~/.cache/tplhalf/{control,h1,h2,h5}.log`. Load before each
19+arm 2.8-4.7, after 2.9-4.4.
20+
21+| past half | film A | film B | wall A | wall B | log |
22+|---|---|---|---|---|---|
23+| 1 (6 future) | +21.1 / -8.9 | +71.2 / -1.9 | 548.5s | 429.1s | h1.log |
24+| **2 (5 future, SHIPS)** | **+20.9 / -9.0** | **+71.0 / -1.8** | 551.3s | 442.3s | h2.log |
25+| 3 (4 future, old default) | +21.1 / -8.9 | +71.5 / -1.5 | 547.0s | 423.0s | control.log |
26+| 5 (2 future) | +21.1 / -8.9 | +71.5 / -1.6 | 561.8s | 438.6s | h5.log |
27+
28+Bracketed: 2 is down on all four columns against 3 (film A -0.2/-0.1,
29+film B -0.5/-0.3), and 1 and 5 are both worse than it on the deciding
30+film B libaom column. Wall of 2 is +0.8% / +4.6% vs 3, under the +15%
31+ceiling. `speed::TPL_FUT_HALF` = 2 at presets 0..=2; presets 3..=6 keep 1
32+(`TPL_DEPTH=4`, unswept).
33+
34+## 3. Budget sweep (`EC_AV1_TPL_FUT_WIN`) at half=2
35+
36+Same gate. `0` means `tpl_depth()-1` = 7. Logs: `h2.log`, `w9.log`,
37+`w11.log`, `h2d10.log`, `w11h3.log`.
38+
39+| window | film A | film B | wall A | wall B | log |
40+|---|---|---|---|---|---|
41+| 7 (`depth-1`) | +20.9 / -9.0 | +71.0 / -1.8 | 551.3s | 442.3s | h2.log |
42+| 9 | +21.0 / -9.0 | +70.7 / -2.0 | 545.3s | 430.2s | w9.log |
43+| **11 (SHIPS at presets 0..=2)** | **+20.9 / -9.0** | **+70.4 / -2.2** | 578.6s | 431.3s | w11.log |
44+| 11, half=3 (split re-check) | +20.9 / -9.0 | +70.9 / -1.9 | 554.8s | 437.7s | w11h3.log |
45+| `TPL_D=10` at half=2 | +21.0 / -9.0 | +70.7 / -2.0 | 543.7s | 435.8s | h2d10.log |
46+
47+11 vs 7: film B -0.6 / -0.4, film A 0.0 / 0.0 -- keep rule (one row
48+>=0.5 down, the other flat). Wall A +5.0%, wall B -2.5%. 11 saturates
49+the one-group lookahead (2 past + 8 future available). Half=3 at the
50+larger budget loses to half=2, so the split does not flip.
51+
52+`TPL_D=10` at half=2 is byte-identical to WIN=9 (same PSNR/bytes on both
53+films): extra depth on non-ARF frames is unused because a pyramid leaf's
54+window is the group's own successors. That is why WIN is its own knob.
55+
56+`speed::TPL_FUT_WIN` = 11 at presets 0..=2; presets 3..=6 keep 0
57+(`depth-1` = 3 at `TPL_DEPTH=4`), unswept.
58+
59+## 4. 12-picture native guard
60+
61+STRUCTURALLY BLIND: `group_target` absorbs a 12-picture tail into one
62+group, so no next group is buffered and mode 2 falls back to the past
63+window. Not re-run; the standing table's 12-frame rows are the guard.
64+
65+## 5. Witness
66+
67+`encoder::tests::the_future_tpl_window_still_codes_every_picture_and_moves_the_stream`
68+already names that mode 2 at the old 3-past split is byte-identical on
69+the 128x128 fixture and that `EC_AV1_TPL_FUT_HALF=1` moves it. No new
70+witness: the long-GOP gate is the measurement.
71+
72+## 6. Other gates
73+
74+Recorded at merge time (this file's suite line). Pins are expected
75+unmoved: the 4-picture pin fixture has no next group, so the fallback
76+keeps the past window.
77+
78+## Deviations
79+
80+* Claude subscription died after the split commit and after the WIN
81+ logs; this close is from those logs plus the WIN default they keep.
82+* Presets 3..=6 split and budget left unswept (named in the tables).
83+* 12-frame rows not re-measured (structurally blind, accepted).
84+
85+## Suite line
86+
87+Pending merge gates on this close.