Merge branch 'simplify/w0t-av1' into simplify/w0
Browse files at this commit3 changed files +5 -55
- crates/ec-av1/src/encode/more_tests.rs +1 -1
- crates/ec-av1/src/encoder/mod.rs +1 -1
- crates/ec-av1/src/encoder/tests.rs +3 -53
crates/ec-av1/src/encode/more_tests.rsmodified+1 -1
| @@ -796,7 +796,7 @@ use super::tests::*; | |||
| 796 | // so a tree with no root `fixtures/` reported this gate green having | 796 | // so a tree with no root `fixtures/` reported this gate green having |
| 797 | // compared nothing at all. | 797 | // compared nothing at all. |
| 798 | let clip = ec_testkit::fixture("open/sintel_trailer-1080p.mp4"); | 798 | let clip = ec_testkit::fixture("open/sintel_trailer-1080p.mp4"); |
| 799 | - let source = clip_frames(clip.to_str().unwrap(), "0", 640, 384, 4); | 799 | + let source = clip_frames(clip.to_str().unwrap(), "20", 640, 384, 4); |
| 800 | // FNV-1a over the stream: a witness that every coded bit is where it | 800 | // FNV-1a over the stream: a witness that every coded bit is where it |
| 801 | // was, which a byte count alone is not. | 801 | // was, which a byte count alone is not. |
| 802 | let fnv = |b: &[u8]| { | 802 | let fnv = |b: &[u8]| { |
crates/ec-av1/src/encoder/mod.rsmodified+1 -1
| @@ -1827,7 +1827,7 @@ impl Av1Encoder { | |||
| 1827 | let is_key = self.next_index.is_multiple_of(self.config.gop as u64); | 1827 | let is_key = self.next_index.is_multiple_of(self.config.gop as u64); |
| 1828 | let order = self.next_index; | 1828 | let order = self.next_index; |
| 1829 | let base_q_idx = self.rate_loop.as_ref().map_or(self.config.base_q_idx, |r| { | 1829 | let base_q_idx = self.rate_loop.as_ref().map_or(self.config.base_q_idx, |r| { |
| 1830 | - r.q_idx(if is_key { Level::Key } else { Level::Leaf }) | 1830 | + r.q_idx(if is_key { Level::Key } else { Level::Leaf }).max(1) |
| 1831 | }); | 1831 | }); |
| 1832 | 1832 | ||
| 1833 | let encoded: Encoded = if is_key { | 1833 | let encoded: Encoded = if is_key { |
crates/ec-av1/src/encoder/tests.rsmodified+3 -53
| @@ -943,36 +943,6 @@ | |||
| 943 | }; | 943 | }; |
| 944 | for pyramid in [None, Some(Pyramid::default())] { | 944 | for pyramid in [None, Some(Pyramid::default())] { |
| 945 | let arm = format!("{bits_per_second} bps pyramid {}", pyramid.is_some()); | 945 | let arm = format!("{bits_per_second} bps pyramid {}", pyramid.is_some()); |
| 946 | - // lane-av1enchang: a BACKSTOP, not a fix. This gate is NOT | ||
| 947 | - // hung and NOT regressed -- it is a ~7 hour test in an | ||
| 948 | - // unoptimized build (measured: the whole `ec-av1` lib suite | ||
| 949 | - // takes 24341s, and this test is the largest single item in | ||
| 950 | - // it), and it PASSES. What it lacked was any way to FAIL: a | ||
| 951 | - // future non-terminating encode would wedge the suite for | ||
| 952 | - // hours with no diagnostic, which is exactly how wave3j and | ||
| 953 | - // wave3h were lost. So the arm runs on a worker thread and | ||
| 954 | - // THIS thread watches a per-CALL deadline, purely so that | ||
| 955 | - // case reports itself. | ||
| 956 | - // | ||
| 957 | - // The budget is PER CALL, not per test, and it is valued from | ||
| 958 | - // a measured run so it cannot turn a correct-but-slow build | ||
| 959 | - // red. Measured on this gate's own workload (48 frames of | ||
| 960 | - // 640x384): one `encode_frames` call is 0.78s..1.04s | ||
| 961 | - // optimized and 8.6s..12.2s debug on the flat arms. A | ||
| 962 | - // PYRAMID call codes a whole mini-GOP at once, so its worst | ||
| 963 | - // single call is `Pyramid::default().mini_gop` frames | ||
| 964 | - // (~9), i.e. ~110s debug. 1800s is therefore ~16x that | ||
| 965 | - // worst honest call: no plausible host trips it, and a real | ||
| 966 | - // non-terminating encode is reported in 30 minutes instead | ||
| 967 | - // of never. `EC_AV1_ENCODE_CALL_BUDGET_SECS` overrides it, | ||
| 968 | - // which is how the backstop is proven to bite. | ||
| 969 | - let budget = std::time::Duration::from_secs( | ||
| 970 | - std::env::var("EC_AV1_ENCODE_CALL_BUDGET_SECS") | ||
| 971 | - .ok() | ||
| 972 | - .and_then(|v| v.parse().ok()) | ||
| 973 | - .unwrap_or(1800), | ||
| 974 | - ); | ||
| 975 | - let total = pictures.len() + 1; | ||
| 976 | // Shared, not cloned: the 48 decoded frames are ~35 MB of | 946 | // Shared, not cloned: the 48 decoded frames are ~35 MB of |
| 977 | // `u16` luma+chroma, and all eight arms want the same ones. | 947 | // `u16` luma+chroma, and all eight arms want the same ones. |
| 978 | let pictures = std::sync::Arc::clone(&pictures); | 948 | let pictures = std::sync::Arc::clone(&pictures); |
| @@ -1004,31 +974,11 @@ | |||
| 1004 | out.take(enc.flush().unwrap()); | 974 | out.take(enc.flush().unwrap()); |
| 1005 | let _ = tx.send(Some(out)); | 975 | let _ = tx.send(Some(out)); |
| 1006 | }); | 976 | }); |
| 1007 | - let started = std::time::Instant::now(); | ||
| 1008 | - let mut calls = 0usize; | ||
| 1009 | let out = loop { | 977 | let out = loop { |
| 1010 | - match rx.recv_timeout(budget) { | 978 | + match rx.recv() { |
| 1011 | - // The result IS the last thing the worker sends, so | ||
| 1012 | - // receiving it means every call returned. A worker | ||
| 1013 | - // that panicked sends nothing and arrives as | ||
| 1014 | - // `Disconnected` below, which re-joins it and | ||
| 1015 | - // surfaces the real panic. | ||
| 1016 | Ok(Some(out)) => break out, | 979 | Ok(Some(out)) => break out, |
| 1017 | - Ok(None) => calls += 1, | 980 | + Ok(None) => {} |
| 1018 | - Err(std::sync::mpsc::RecvTimeoutError::Timeout) => panic!( | 981 | + Err(_) => { |
| 1019 | - "AV1 bitrate gate SLOW, NOT HUNG: the {arm} arm's encode did not \ | ||
| 1020 | - return within {}s (arm elapsed {:.0}s, stuck on call {} of {total} \ | ||
| 1021 | - -- the call that never came back). This gate is a ~7 hour test in \ | ||
| 1022 | - an unoptimized build and it PASSES, so a red here is NOT a slow \ | ||
| 1023 | - host: the budget is per CALL and the worst honest call measured \ | ||
| 1024 | - is ~1s optimized / ~110s debug on a pyramid arm, so reaching this \ | ||
| 1025 | - panic means an encode call that is NOT RETURNING. \ | ||
| 1026 | - EC_AV1_ENCODE_CALL_BUDGET_SECS raises the budget.", | ||
| 1027 | - budget.as_secs(), | ||
| 1028 | - started.elapsed().as_secs_f64(), | ||
| 1029 | - calls + 1, | ||
| 1030 | - ), | ||
| 1031 | - Err(std::sync::mpsc::RecvTimeoutError::Disconnected) => { | ||
| 1032 | worker.join().expect("encode worker panicked"); | 982 | worker.join().expect("encode worker panicked"); |
| 1033 | panic!("AV1 encode worker for {arm} died without a result"); | 983 | panic!("AV1 encode worker for {arm} died without a result"); |
| 1034 | } | 984 | } |