feat(loss-harness): sweep the streamed-AU wire shape alongside whole-AU
The Phase-2 gate: more, smaller wire units must not regress FEC recovery. Adds a GF16 streamed column (three chunk pushes + finish per AU — sentinel blocks then real totals). Measured: identical to whole-AU at every loss rate (50/50 through 1/6, the same 25%-budget cliff). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,16 +31,41 @@ fn config(role: Role, scheme: FecScheme, drop_period: u32) -> Config {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns (frames_completed, frames_attempted) for a loss setting.
|
||||
fn run(scheme: FecScheme, drop_period: u32, frames: usize, frame_len: usize) -> (usize, usize) {
|
||||
/// Returns (frames_completed, frames_attempted) for a loss setting. `streamed` feeds each AU
|
||||
/// through the VIDEO_CAP_STREAMED_AU path (three encoder-chunk pushes + finish — sentinel
|
||||
/// blocks then real totals) instead of one whole-AU submit, so the two wire shapes' recovery
|
||||
/// curves can be compared directly (the Phase-2 "more, smaller units must not regress FEC" gate).
|
||||
fn run(
|
||||
scheme: FecScheme,
|
||||
drop_period: u32,
|
||||
frames: usize,
|
||||
frame_len: usize,
|
||||
streamed: bool,
|
||||
) -> (usize, usize) {
|
||||
let (h, c) = loopback_pair(drop_period, 0);
|
||||
let mut host = Session::new(config(Role::Host, scheme, drop_period), Box::new(h)).unwrap();
|
||||
let mut client = Session::new(config(Role::Client, scheme, drop_period), Box::new(c)).unwrap();
|
||||
|
||||
let mut send_wires = |host: &mut Session, wires: Vec<Vec<u8>>| {
|
||||
let refs: Vec<&[u8]> = wires.iter().map(|w| w.as_slice()).collect();
|
||||
host.send_sealed(&refs).unwrap();
|
||||
drop(refs);
|
||||
host.reclaim_wires(wires);
|
||||
};
|
||||
let mut completed = 0;
|
||||
for f in 0..frames {
|
||||
let frame: Vec<u8> = (0..frame_len).map(|b| (b ^ f) as u8).collect();
|
||||
if streamed {
|
||||
let mut au = host.begin_streamed_frame_at(f as u64, 0, f as u32).unwrap();
|
||||
for chunk in frame.chunks(frame_len / 3 + 1) {
|
||||
let wires = host.seal_streamed_chunk(&mut au, chunk).unwrap();
|
||||
send_wires(&mut host, wires);
|
||||
}
|
||||
let wires = host.seal_streamed_finish(au).unwrap();
|
||||
send_wires(&mut host, wires);
|
||||
} else {
|
||||
host.submit_frame(&frame, f as u64, 0).unwrap();
|
||||
}
|
||||
match client.poll_frame() {
|
||||
Ok(got) => {
|
||||
if got.data == frame {
|
||||
@@ -60,22 +85,26 @@ fn main() {
|
||||
let periods = [0u32, 32, 16, 8, 6, 4, 3, 2];
|
||||
|
||||
println!("punktfunk loss-harness — 25% FEC, {frames} frames of {frame_len} bytes");
|
||||
println!("(GF8 = P1/GameStream-compat, GF16 = P2/wall-breaker)\n");
|
||||
println!("(GF8 = P1/GameStream-compat, GF16 = P2/wall-breaker, strm = streamed-AU wire)\n");
|
||||
println!(
|
||||
"{:>10} {:>9} {:>14} {:>14}",
|
||||
"drop 1/N", "~loss %", "GF8 recovered", "GF16 recovered"
|
||||
"{:>10} {:>9} {:>14} {:>14} {:>14}",
|
||||
"drop 1/N", "~loss %", "GF8 recovered", "GF16 recovered", "GF16 strm"
|
||||
);
|
||||
println!("{}", "-".repeat(56));
|
||||
println!("{}", "-".repeat(72));
|
||||
for &p in &periods {
|
||||
let loss = if p == 0 { 0.0 } else { 100.0 / p as f64 };
|
||||
let (g8, n) = run(FecScheme::Gf8, p, frames, frame_len);
|
||||
let (g16, _) = run(FecScheme::Gf16, p, frames, frame_len);
|
||||
let (g8, n) = run(FecScheme::Gf8, p, frames, frame_len, false);
|
||||
let (g16, _) = run(FecScheme::Gf16, p, frames, frame_len, false);
|
||||
let (g16s, _) = run(FecScheme::Gf16, p, frames, frame_len, true);
|
||||
let label = if p == 0 {
|
||||
"none".to_string()
|
||||
} else {
|
||||
format!("1/{p}")
|
||||
};
|
||||
println!("{label:>10} {loss:>8.1}% {:>11}/{n} {:>11}/{n}", g8, g16);
|
||||
println!(
|
||||
"{label:>10} {loss:>8.1}% {:>11}/{n} {:>11}/{n} {:>11}/{n}",
|
||||
g8, g16, g16s
|
||||
);
|
||||
}
|
||||
println!("\nNote: recovery drops off once per-block loss exceeds the 25% recovery budget.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user