From c245a3144fa6629885693197da757cf3cb606e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Dec 2026 06:44:21 +0300 Subject: [PATCH] ec-av1 bitrate gate: drop the per-call wall-clock budget (recv_timeout SLOW panic); owner rule bans wall-clock gates, the blocking recv still reports a worker panic --- crates/ec-av1/src/encoder/tests.rs | 56 ++---------------------------- 1 file changed, 3 insertions(+), 53 deletions(-) diff --git a/crates/ec-av1/src/encoder/tests.rs b/crates/ec-av1/src/encoder/tests.rs index c0b7fac1..51a6257b 100644 --- a/crates/ec-av1/src/encoder/tests.rs +++ b/crates/ec-av1/src/encoder/tests.rs @@ -943,36 +943,6 @@ }; for pyramid in [None, Some(Pyramid::default())] { let arm = format!("{bits_per_second} bps pyramid {}", pyramid.is_some()); - // lane-av1enchang: a BACKSTOP, not a fix. This gate is NOT - // hung and NOT regressed -- it is a ~7 hour test in an - // unoptimized build (measured: the whole `ec-av1` lib suite - // takes 24341s, and this test is the largest single item in - // it), and it PASSES. What it lacked was any way to FAIL: a - // future non-terminating encode would wedge the suite for - // hours with no diagnostic, which is exactly how wave3j and - // wave3h were lost. So the arm runs on a worker thread and - // THIS thread watches a per-CALL deadline, purely so that - // case reports itself. - // - // The budget is PER CALL, not per test, and it is valued from - // a measured run so it cannot turn a correct-but-slow build - // red. Measured on this gate's own workload (48 frames of - // 640x384): one `encode_frames` call is 0.78s..1.04s - // optimized and 8.6s..12.2s debug on the flat arms. A - // PYRAMID call codes a whole mini-GOP at once, so its worst - // single call is `Pyramid::default().mini_gop` frames - // (~9), i.e. ~110s debug. 1800s is therefore ~16x that - // worst honest call: no plausible host trips it, and a real - // non-terminating encode is reported in 30 minutes instead - // of never. `EC_AV1_ENCODE_CALL_BUDGET_SECS` overrides it, - // which is how the backstop is proven to bite. - let budget = std::time::Duration::from_secs( - std::env::var("EC_AV1_ENCODE_CALL_BUDGET_SECS") - .ok() - .and_then(|v| v.parse().ok()) - .unwrap_or(1800), - ); - let total = pictures.len() + 1; // Shared, not cloned: the 48 decoded frames are ~35 MB of // `u16` luma+chroma, and all eight arms want the same ones. let pictures = std::sync::Arc::clone(&pictures); @@ -1004,31 +974,11 @@ out.take(enc.flush().unwrap()); let _ = tx.send(Some(out)); }); - let started = std::time::Instant::now(); - let mut calls = 0usize; let out = loop { - match rx.recv_timeout(budget) { - // The result IS the last thing the worker sends, so - // receiving it means every call returned. A worker - // that panicked sends nothing and arrives as - // `Disconnected` below, which re-joins it and - // surfaces the real panic. + match rx.recv() { Ok(Some(out)) => break out, - Ok(None) => calls += 1, - Err(std::sync::mpsc::RecvTimeoutError::Timeout) => panic!( - "AV1 bitrate gate SLOW, NOT HUNG: the {arm} arm's encode did not \ - return within {}s (arm elapsed {:.0}s, stuck on call {} of {total} \ - -- the call that never came back). This gate is a ~7 hour test in \ - an unoptimized build and it PASSES, so a red here is NOT a slow \ - host: the budget is per CALL and the worst honest call measured \ - is ~1s optimized / ~110s debug on a pyramid arm, so reaching this \ - panic means an encode call that is NOT RETURNING. \ - EC_AV1_ENCODE_CALL_BUDGET_SECS raises the budget.", - budget.as_secs(), - started.elapsed().as_secs_f64(), - calls + 1, - ), - Err(std::sync::mpsc::RecvTimeoutError::Disconnected) => { + Ok(None) => {} + Err(_) => { worker.join().expect("encode worker panicked"); panic!("AV1 encode worker for {arm} died without a result"); }