Merge lane/av1uballoc: the plane allocation is zeroed, because a number said so
Browse files at this commit4 changed files +1066 -90
- crates/ec-av1/examples/alloc_timing.rs +105 -0
- crates/ec-av1/src/decode.rs +314 -90
- crates/ec-av1/src/stream.rs +233 -0
- lanes/av1uballoc.report.md +414 -0
crates/ec-av1/examples/alloc_timing.rsadded+105 -0
| @@ -0,0 +1,105 @@ | |||
| 1 | +//! Decode wall time and minor page faults for one `EC_AV1_PLANE_ALLOC` arm. | ||
| 2 | +//! | ||
| 3 | +//! The three closures lane-uballoc had to choose between (see | ||
| 4 | +//! `lanes/av1uballoc.report.md`) are selected by `EC_AV1_PLANE_ALLOC` inside | ||
| 5 | +//! the crate, not by a build flag -- see [`ec_av1`]'s `fresh_plane`. Measuring | ||
| 6 | +//! them that way means all arms share one binary, one allocator state and one | ||
| 7 | +//! machine, which three separate builds cannot do. | ||
| 8 | +//! | ||
| 9 | +//! ```text | ||
| 10 | +//! EC_AV1_PLANE_ALLOC=zeroed cargo run -p ec-av1 --release --example alloc_timing -- s.obu | ||
| 11 | +//! ``` | ||
| 12 | +//! | ||
| 13 | +//! One process does ONE decode and prints ONE line, so the harness interleaves | ||
| 14 | +//! arms across processes instead of trusting one process's warm-up history: | ||
| 15 | +//! | ||
| 16 | +//! ```text | ||
| 17 | +//! ALLOC_TIMING arm=zeroed frames=24 wall_ms=1234.567 minflt=61234 majflt=0 hash=8f2a... | ||
| 18 | +//! ``` | ||
| 19 | +//! | ||
| 20 | +//! `hash` is FNV-1a over every picture's Y/U/V samples in decode order. It is | ||
| 21 | +//! the cross-arm determinism evidence: identical `hash` on every arm means the | ||
| 22 | +//! closure chosen does not move a single output sample. | ||
| 23 | +use std::time::Instant; | ||
| 24 | + | ||
| 25 | +const FNV_OFFSET: u64 = 0xcbf2_9ce4_8422_2325; | ||
| 26 | +const FNV_PRIME: u64 = 0x0000_0100_0000_01b3; | ||
| 27 | + | ||
| 28 | +/// Minor/major faults from `/proc/self/stat` fields 10 and 12, read around the | ||
| 29 | +/// decode. A zeroed-from-the-kernel allocation and an explicit memset differ in | ||
| 30 | +/// how many pages they actually touch, and that is the only cheap proxy for it | ||
| 31 | +/// that does not need `perf`. | ||
| 32 | +fn faults() -> (u64, u64) { | ||
| 33 | + let stat = std::fs::read_to_string("/proc/self/stat").unwrap_or_default(); | ||
| 34 | + // Everything before the last ')' is pid + comm, and comm may hold spaces. | ||
| 35 | + let Some(rest) = stat.rsplit_once(')').map(|(_, r)| r) else { | ||
| 36 | + return (0, 0); | ||
| 37 | + }; | ||
| 38 | + let f: Vec<&str> = rest.split_whitespace().collect(); | ||
| 39 | + // `rest` starts at field 3 (state); minflt is field 10, majflt field 12. | ||
| 40 | + ( | ||
| 41 | + f.get(7).and_then(|v| v.parse().ok()).unwrap_or(0), | ||
| 42 | + f.get(9).and_then(|v| v.parse().ok()).unwrap_or(0), | ||
| 43 | + ) | ||
| 44 | +} | ||
| 45 | + | ||
| 46 | +fn fnv1a(mut h: u64, bytes: &[u8]) -> u64 { | ||
| 47 | + for &b in bytes { | ||
| 48 | + h ^= u64::from(b); | ||
| 49 | + h = h.wrapping_mul(FNV_PRIME); | ||
| 50 | + } | ||
| 51 | + h | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | +fn main() { | ||
| 55 | + let mut args = std::env::args().skip(1); | ||
| 56 | + let Some(path) = args.next() else { | ||
| 57 | + eprintln!("usage: alloc_timing <stream.obu>"); | ||
| 58 | + std::process::exit(2); | ||
| 59 | + }; | ||
| 60 | + let arm = std::env::var("EC_AV1_PLANE_ALLOC").unwrap_or_else(|_| "<unset>".into()); | ||
| 61 | + let data = match std::fs::read(&path) { | ||
| 62 | + Ok(d) => d, | ||
| 63 | + Err(e) => { | ||
| 64 | + eprintln!("{path}: {e}"); | ||
| 65 | + std::process::exit(2); | ||
| 66 | + } | ||
| 67 | + }; | ||
| 68 | + | ||
| 69 | + // One warm-up decode is NOT done here on purpose: the plane allocations are | ||
| 70 | + // freed back to the allocator between frames anyway, and a discarded decode | ||
| 71 | + // would only hand one arm a warmer arena than another. The harness runs | ||
| 72 | + // each arm many times and reports the median. | ||
| 73 | + let (minflt0, majflt0) = faults(); | ||
| 74 | + let t0 = Instant::now(); | ||
| 75 | + let mut frames = 0usize; | ||
| 76 | + let mut hash = FNV_OFFSET; | ||
| 77 | + let r = ec_av1::stream::decode_stream_with(&data, |pic, _idx, shown| { | ||
| 78 | + if !shown { | ||
| 79 | + return Ok(()); | ||
| 80 | + } | ||
| 81 | + frames += 1; | ||
| 82 | + for p in [&pic.y, &pic.u, &pic.v] { | ||
| 83 | + let mut buf = Vec::with_capacity(p.len() * 2); | ||
| 84 | + for &s in p.iter() { | ||
| 85 | + buf.extend_from_slice(&s.to_le_bytes()); | ||
| 86 | + } | ||
| 87 | + hash = fnv1a(hash, &buf); | ||
| 88 | + } | ||
| 89 | + Ok(()) | ||
| 90 | + }); | ||
| 91 | + let wall = t0.elapsed(); | ||
| 92 | + let (minflt1, majflt1) = faults(); | ||
| 93 | + match r { | ||
| 94 | + Ok(()) => println!( | ||
| 95 | + "ALLOC_TIMING arm={arm} frames={frames} wall_ms={:.3} minflt={} majflt={} hash={hash:016x}", | ||
| 96 | + wall.as_secs_f64() * 1e3, | ||
| 97 | + minflt1.saturating_sub(minflt0), | ||
| 98 | + majflt1.saturating_sub(majflt0), | ||
| 99 | + ), | ||
| 100 | + Err(e) => { | ||
| 101 | + eprintln!("{path}: decode refused: {e}"); | ||
| 102 | + std::process::exit(3); | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | +} | ||
crates/ec-av1/src/decode.rsmodified+314 -90
| @@ -21285,9 +21285,9 @@ fn dump_prefilter_wide(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { | |||
| 21285 | 21285 | ||
| 21286 | /// Enabled by `EC_AV1_PLANE_SENTINEL` (there is no separate flag for it): print | 21286 | /// Enabled by `EC_AV1_PLANE_SENTINEL` (there is no separate flag for it): print |
| 21287 | /// an EXACT census of the samples the tile walk never wrote -- with it, every | 21287 | /// an EXACT census of the samples the tile walk never wrote -- with it, every |
| 21288 | -/// plane still holding [`PLANE_SENTINEL`] at this point is a sample no block | 21288 | +/// plane still holding [`plane_poison`] at this point is a sample no block |
| 21289 | -/// reconstructed, and no legal sample can equal `0xDEAD` (reconstruction clamps | 21289 | +/// reconstructed, and no legal sample can equal the poison (reconstruction |
| 21290 | -/// to `(1 << bit_depth) - 1`). | 21290 | +/// clamps to `(1 << bit_depth) - 1`, at most 4095). |
| 21291 | /// | 21291 | /// |
| 21292 | /// Coverage, stated as the code has it: this census runs at TWO of the four | 21292 | /// Coverage, stated as the code has it: this census runs at TWO of the four |
| 21293 | /// places [`apply_deblock`] is entered from -- the key-frame path and the | 21293 | /// places [`apply_deblock`] is entered from -- the key-frame path and the |
| @@ -21304,43 +21304,74 @@ fn dump_prefilter_wide(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { | |||
| 21304 | /// `lane/av1422seed` census used: it replaces a wrong-sample diff (which says | 21304 | /// `lane/av1422seed` census used: it replaces a wrong-sample diff (which says |
| 21305 | /// where the OUTPUT is wrong, not whether the block was written at all) with a | 21305 | /// where the OUTPUT is wrong, not whether the block was written at all) with a |
| 21306 | /// direct count plus the coordinates of every hole, grouped into per-row | 21306 | /// direct count plus the coordinates of every hole, grouped into per-row |
| 21307 | -/// spans so a large hole stays readable. Scans each plane over its own | 21307 | +/// spans so a large hole stays readable. |
| 21308 | -/// `true_width` x `true_height` extent, PER AXIS (`true_width.min(p.width)`), so | 21308 | +/// |
| 21309 | -/// a 4:2:2 frame's chroma is scanned at its own `fw/2 x fh` shape rather than | 21309 | +/// It scans TWO regions per plane, because they answer different questions and |
| 21310 | -/// the 4:2:0 `div_ceil(2)` crop the older [`dump_stage16`] used: past that | 21310 | +/// the earlier revision only scanned one of them: |
| 21311 | -/// extent is the padded coding surface's invented tail, which no decoder ever | 21311 | +/// * the TRUE EXTENT -- each plane over its own `true_width` x `true_height`, |
| 21312 | -/// reads. | 21312 | +/// PER AXIS (`true_width.min(p.width)`), so a 4:2:2 frame's chroma is scanned |
| 21313 | +/// at its own `fw/2 x fh` shape rather than the 4:2:0 `div_ceil(2)` crop the | ||
| 21314 | +/// older [`dump_stage16`] used. A hole here can reach the caller, and it is | ||
| 21315 | +/// the region lane/av1unwritten's 224 samples sat in. | ||
| 21316 | +/// * the PADDED TAIL -- everything outside that extent, out to the block-aligned | ||
| 21317 | +/// coding surface -- counted separately into [`PAD_UNWRITTEN_SAMPLES`]. The | ||
| 21318 | +/// earlier revision's doc comment asserted "past that is the padded coding | ||
| 21319 | +/// surface's invented tail, which no decoder ever reads". That assertion is | ||
| 21320 | +/// exactly what a tail that is never written and never read looks like, so it | ||
| 21321 | +/// was self-certifying; the tail is now scanned and counted like any other | ||
| 21322 | +/// region. `EC_AV1_PLANE_ALLOC=padzero`/`extzero` attribute a read to one | ||
| 21323 | +/// side or the other (see [`fresh_plane`]). | ||
| 21313 | fn census_unwritten(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { | 21324 | fn census_unwritten(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { |
| 21314 | if !plane_sentinel_on() { | 21325 | if !plane_sentinel_on() { |
| 21315 | return; | 21326 | return; |
| 21316 | } | 21327 | } |
| 21328 | + let poison = plane_poison(); | ||
| 21317 | let idx = PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst); | 21329 | let idx = PREFILT_PICTURE_IDX.load(std::sync::atomic::Ordering::SeqCst); |
| 21318 | for (name, p) in [("Y", y), ("U", u), ("V", v)] { | 21330 | for (name, p) in [("Y", y), ("U", u), ("V", v)] { |
| 21319 | - let (w, h) = (p.true_width.min(p.width), p.true_height); | 21331 | + let (w, h) = (p.true_width.min(p.width), p.true_height.min(p.height)); |
| 21320 | let mut total = 0usize; | 21332 | let mut total = 0usize; |
| 21321 | let mut spans: Vec<(usize, usize, usize)> = Vec::new(); | 21333 | let mut spans: Vec<(usize, usize, usize)> = Vec::new(); |
| 21322 | for row in 0..h { | 21334 | for row in 0..h { |
| 21323 | let mut run: Option<(usize, usize)> = None; | 21335 | let mut run: Option<(usize, usize)> = None; |
| 21324 | for col in 0..w { | 21336 | for col in 0..w { |
| 21325 | - if p.data[row * p.width + col] == PLANE_SENTINEL { | 21337 | + if p.data[row * p.width + col] == poison { |
| 21326 | total += 1; | 21338 | total += 1; |
| 21327 | run = Some(match run { | 21339 | run = Some(match run { |
| 21328 | None => (col, col), | 21340 | None => (col, col), |
| 21329 | Some((a, _)) => (a, col), | 21341 | Some((a, _)) => (a, col), |
| 21330 | }); | 21342 | }); |
| 21331 | } | 21343 | } |
| 21332 | - if run.is_some() | 21344 | + if run.is_some() && (col + 1 == w || p.data[row * p.width + col + 1] != poison) { |
| 21333 | - && (col + 1 == w || p.data[row * p.width + col + 1] != PLANE_SENTINEL) | ||
| 21334 | - { | ||
| 21335 | let (a, b) = run.take().expect("a run is open here"); | 21345 | let (a, b) = run.take().expect("a run is open here"); |
| 21336 | spans.push((row, a, b)); | 21346 | spans.push((row, a, b)); |
| 21337 | } | 21347 | } |
| 21338 | } | 21348 | } |
| 21339 | } | 21349 | } |
| 21350 | + // The padded tail: columns `w..width` on rows `0..h`, plus every column | ||
| 21351 | + // on rows `h..height`. | ||
| 21352 | + let mut pad_total = 0usize; | ||
| 21353 | + let mut pad_scanned = 0usize; | ||
| 21354 | + for row in 0..p.height { | ||
| 21355 | + let (from, to) = if row < h { (w, p.width) } else { (0, p.width) }; | ||
| 21356 | + if from >= to { | ||
| 21357 | + continue; | ||
| 21358 | + } | ||
| 21359 | + pad_scanned += to - from; | ||
| 21360 | + pad_total += p.data[row * p.width + from..row * p.width + to] | ||
| 21361 | + .iter() | ||
| 21362 | + .filter(|&&s| s == poison) | ||
| 21363 | + .count(); | ||
| 21364 | + } | ||
| 21340 | UNWRITTEN_SAMPLES.fetch_add(total, std::sync::atomic::Ordering::SeqCst); | 21365 | UNWRITTEN_SAMPLES.fetch_add(total, std::sync::atomic::Ordering::SeqCst); |
| 21341 | CENSUS_SCANNED.fetch_add(w * h, std::sync::atomic::Ordering::SeqCst); | 21366 | CENSUS_SCANNED.fetch_add(w * h, std::sync::atomic::Ordering::SeqCst); |
| 21367 | + PAD_UNWRITTEN_SAMPLES.fetch_add(pad_total, std::sync::atomic::Ordering::SeqCst); | ||
| 21368 | + PAD_CENSUS_SCANNED.fetch_add(pad_scanned, std::sync::atomic::Ordering::SeqCst); | ||
| 21369 | + eprintln!( | ||
| 21370 | + "SENTINEL_CENSUS idx={idx} plane={name} surface={}x{} extent={w}x{h} \ | ||
| 21371 | + pad_scanned={pad_scanned} unwritten={total} pad_unwritten={pad_total}", | ||
| 21372 | + p.width, p.height, | ||
| 21373 | + ); | ||
| 21342 | if total == 0 { | 21374 | if total == 0 { |
| 21343 | - eprintln!("SENTINEL_CENSUS idx={idx} plane={name} extent={w}x{h} unwritten=0"); | ||
| 21344 | continue; | 21375 | continue; |
| 21345 | } | 21376 | } |
| 21346 | let body: Vec<String> = spans | 21377 | let body: Vec<String> = spans |
| @@ -21348,8 +21379,10 @@ fn census_unwritten(y: &PlaneBuf<'_>, u: &PlaneBuf<'_>, v: &PlaneBuf<'_>) { | |||
| 21348 | .map(|&(r, a, b)| format!("y{r} x{a}..={b}")) | 21379 | .map(|&(r, a, b)| format!("y{r} x{a}..={b}")) |
| 21349 | .collect(); | 21380 | .collect(); |
| 21350 | eprintln!( | 21381 | eprintln!( |
| 21351 | - "SENTINEL_CENSUS idx={idx} plane={name} extent={w}x{h} unwritten={total} \ | 21382 | + "SENTINEL_CENSUS idx={idx} plane={name} surface={}x{} extent={w}x{h} \ |
| 21352 | - spans={}: {}", | 21383 | + unwritten={total} spans={}: {}", |
| 21384 | + p.width, | ||
| 21385 | + p.height, | ||
| 21353 | spans.len(), | 21386 | spans.len(), |
| 21354 | body.join(" ") | 21387 | body.join(" ") |
| 21355 | ); | 21388 | ); |
| @@ -21392,6 +21425,67 @@ pub fn take_census_scanned() -> usize { | |||
| 21392 | CENSUS_SCANNED.swap(0, std::sync::atomic::Ordering::SeqCst) | 21425 | CENSUS_SCANNED.swap(0, std::sync::atomic::Ordering::SeqCst) |
| 21393 | } | 21426 | } |
| 21394 | 21427 | ||
| 21428 | +/// Samples in the PADDED TAIL -- every sample of each plane outside its own | ||
| 21429 | +/// `true_width` x `true_height` extent -- that still holds [`plane_poison`] at | ||
| 21430 | +/// the pre-deblock point. [`census_unwritten`] scans that region too, because | ||
| 21431 | +/// "past the true extent nothing is ever read" was an ASSUMPTION the tail's | ||
| 21432 | +/// census was built to avoid checking; this counter is the measurement. | ||
| 21433 | +static PAD_UNWRITTEN_SAMPLES: std::sync::atomic::AtomicUsize = | ||
| 21434 | + std::sync::atomic::AtomicUsize::new(0); | ||
| 21435 | + | ||
| 21436 | +/// Samples [`census_unwritten`] scanned in the padded tail, paired with | ||
| 21437 | +/// [`PAD_UNWRITTEN_SAMPLES`] for the same reason as [`CENSUS_SCANNED`]. | ||
| 21438 | +static PAD_CENSUS_SCANNED: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicUsize::new(0); | ||
| 21439 | + | ||
| 21440 | +/// Reads and clears [`PAD_UNWRITTEN_SAMPLES`]. | ||
| 21441 | +pub fn take_pad_unwritten_samples() -> usize { | ||
| 21442 | + PAD_UNWRITTEN_SAMPLES.swap(0, std::sync::atomic::Ordering::SeqCst) | ||
| 21443 | +} | ||
| 21444 | + | ||
| 21445 | +/// Reads and clears [`PAD_CENSUS_SCANNED`]. | ||
| 21446 | +pub fn take_pad_census_scanned() -> usize { | ||
| 21447 | + PAD_CENSUS_SCANNED.swap(0, std::sync::atomic::Ordering::SeqCst) | ||
| 21448 | +} | ||
| 21449 | + | ||
| 21450 | +/// The largest value reconstruction can produce, `(1 << 12) - 1`: the highest | ||
| 21451 | +/// bit depth this decoder carries is 12. A sentinel at or below this could be | ||
| 21452 | +/// a LEGAL sample, which would make the whole census vacuous -- every | ||
| 21453 | +/// unwritten sample would look like an ordinary one. | ||
| 21454 | +const MAX_LEGAL_SAMPLE: u16 = 4095; | ||
| 21455 | + | ||
| 21456 | +/// The value [`fresh_plane`] fills with when the sentinel is on. | ||
| 21457 | +/// | ||
| 21458 | +/// [`PLANE_SENTINEL`] unless `EC_AV1_PLANE_SENTINEL` names a different one in | ||
| 21459 | +/// hex. Two different poisons are what turns the sentinel from "did a hole | ||
| 21460 | +/// survive into the output" into "did the output depend on the buffer's | ||
| 21461 | +/// initial content": a hole whose value reaches the picture changes the hash | ||
| 21462 | +/// when the poison changes, and one that does not cannot have influenced | ||
| 21463 | +/// anything. A value at or below [`MAX_LEGAL_SAMPLE`] is REFUSED (falls back | ||
| 21464 | +/// to [`PLANE_SENTINEL`]) because the census's soundness rests on the sentinel | ||
| 21465 | +/// being impossible. `EC_AV1_PLANE_SENTINEL=1` -- the spelling every existing | ||
| 21466 | +/// caller and gate uses, and `env_flag!`'s mere presence test -- keeps | ||
| 21467 | +/// [`PLANE_SENTINEL`]. | ||
| 21468 | +fn plane_poison() -> u16 { | ||
| 21469 | + static V: std::sync::LazyLock<u16> = std::sync::LazyLock::new(|| { | ||
| 21470 | + let Ok(raw) = crate::envflags::var("EC_AV1_PLANE_SENTINEL") else { | ||
| 21471 | + return PLANE_SENTINEL; | ||
| 21472 | + }; | ||
| 21473 | + let t = raw.trim(); | ||
| 21474 | + if t.is_empty() || t == "1" { | ||
| 21475 | + return PLANE_SENTINEL; | ||
| 21476 | + } | ||
| 21477 | + let hex = t | ||
| 21478 | + .strip_prefix("0x") | ||
| 21479 | + .or_else(|| t.strip_prefix("0X")) | ||
| 21480 | + .unwrap_or(t); | ||
| 21481 | + match u16::from_str_radix(hex, 16) { | ||
| 21482 | + Ok(v) if v > MAX_LEGAL_SAMPLE => v, | ||
| 21483 | + _ => PLANE_SENTINEL, | ||
| 21484 | + } | ||
| 21485 | + }); | ||
| 21486 | + *V | ||
| 21487 | +} | ||
| 21488 | + | ||
| 21395 | thread_local! { | 21489 | thread_local! { |
| 21396 | /// The [`set_plane_sentinel`] override; `EC_AV1_PLANE_SENTINEL` is the | 21490 | /// The [`set_plane_sentinel`] override; `EC_AV1_PLANE_SENTINEL` is the |
| 21397 | /// process-wide default. | 21491 | /// process-wide default. |
| @@ -21777,92 +21871,210 @@ pub(crate) fn census_unwritten_final(y: &[u16], u: &[u16], v: &[u16]) { | |||
| 21777 | // each plane IS the true-extent count. | 21871 | // each plane IS the true-extent count. |
| 21778 | let (scanned, total): (usize, usize) = [y, u, v] | 21872 | let (scanned, total): (usize, usize) = [y, u, v] |
| 21779 | .iter() | 21873 | .iter() |
| 21780 | - .map(|p| (p.len(), p.iter().filter(|&&s| s == PLANE_SENTINEL).count())) | 21874 | + .map(|p| (p.len(), p.iter().filter(|&&s| s == plane_poison()).count())) |
| 21781 | .fold((0, 0), |(a, b), (c, d)| (a + c, b + d)); | 21875 | .fold((0, 0), |(a, b), (c, d)| (a + c, b + d)); |
| 21782 | FINAL_CENSUS_SCANNED.fetch_add(scanned, std::sync::atomic::Ordering::SeqCst); | 21876 | FINAL_CENSUS_SCANNED.fetch_add(scanned, std::sync::atomic::Ordering::SeqCst); |
| 21783 | FINAL_UNWRITTEN_SAMPLES.fetch_add(total, std::sync::atomic::Ordering::SeqCst); | 21877 | FINAL_UNWRITTEN_SAMPLES.fetch_add(total, std::sync::atomic::Ordering::SeqCst); |
| 21784 | } | 21878 | } |
| 21785 | 21879 | ||
| 21786 | -/// A frame plane's own backing store, `n` samples, UNINITIALISED. | 21880 | +/// Which closure [`fresh_plane`] applies to the allocation it hands back. |
| 21787 | /// | 21881 | /// |
| 21788 | -/// (lane-picalloc) Replaced a `vec![0u16; n]` that zeroed the whole plane | 21882 | +/// # WHY AN ENV ARM, and what each arm is |
| 21789 | -/// buffer: ~3% of the frame thread's cycles at 4K, serially at the frame's head, | ||
| 21790 | -/// to initialise 25 MB the next pass overwrites. | ||
| 21791 | /// | 21883 | /// |
| 21792 | -/// # THE `unsafe` BELOW IS NOT FULLY JUSTIFIED -- read this before approving it | 21884 | +/// The closure was a filed choice with no number behind it |
| 21885 | +/// (`lanes/unwritten-dep.report.md` §12). lane-av1uballoc measured all of them | ||
| 21886 | +/// on one stream in ONE binary, because three separate builds cannot make the | ||
| 21887 | +/// comparison fair -- the allocator's recycled-arena state, the page-cache | ||
| 21888 | +/// state and the code layout all differ between them. `EC_AV1_PLANE_ALLOC` | ||
| 21889 | +/// (process-constant, read once -- see [`crate::envflags`]) picks the arm. | ||
| 21890 | +/// Numbers: `lanes/av1uballoc.report.md`. | ||
| 21891 | +#[derive(Clone, Copy, PartialEq, Eq, Debug)] | ||
| 21892 | +enum PlaneAlloc { | ||
| 21893 | + /// `vec![0u16; n]`, i.e. `alloc_zeroed`/`calloc`. **The default and the | ||
| 21894 | + /// shipped closure.** It removes the `unsafe` below from every build that | ||
| 21895 | + /// does not ask for a census arm. | ||
| 21896 | + /// | ||
| 21897 | + /// What it costs, measured on one stream in one binary | ||
| 21898 | + /// (`lanes/av1uballoc.report.md` §1): **+0.84%** of decode wall time at | ||
| 21899 | + /// 3840x2160 4:2:0 (96 frames, 6937.728 -> 6995.727 ms, mean 6995.769, | ||
| 21900 | + /// run-to-run spread of the arm 10.2 ms, so ~6 sigma), **+0.81%** at | ||
| 21901 | + /// 3840x2160 4:2:2, and **-1.63%** at 1920x1080 4:2:0 -- it is FASTER | ||
| 21902 | + /// there, reproducibly. The sign flip is not explained here; the numbers | ||
| 21903 | + /// are. | ||
| 21904 | + /// | ||
| 21905 | + /// What it is NOT is the "zero pages are free" story the arm's name | ||
| 21906 | + /// invites: glibc hands a RECYCLED arena block back from `calloc` with the | ||
| 21907 | + /// same memset an explicit fill does, which is why this arm and | ||
| 21908 | + /// [`PlaneAlloc::Fill`] land within 0.03% of each other at every size. | ||
| 21909 | + Zeroed, | ||
| 21910 | + /// The status quo this lane replaced: `Vec::with_capacity` + `set_len`, | ||
| 21911 | + /// nothing written. Kept as an arm because every number here is a delta | ||
| 21912 | + /// against it, and because `EC_AV1_PLANE_ALLOC=uninit` reproduces it. | ||
| 21913 | + Uninit, | ||
| 21914 | + /// An explicit zero-fill (`Vec::with_capacity` then `resize(n, 0)`) -- the | ||
| 21915 | + /// closure that costs the same as [`PlaneAlloc::Zeroed`]. Kept so the | ||
| 21916 | + /// "zero pages are free" hypothesis stays falsifiable from the outside. | ||
| 21917 | + Fill, | ||
| 21918 | + /// Census-only: zero the PADDED tail (everything outside the plane's true | ||
| 21919 | + /// extent) and leave the true extent uninitialised. Pairs with | ||
| 21920 | + /// [`PlaneAlloc::ExtZero`] to attribute a read to one region. | ||
| 21921 | + PadZero, | ||
| 21922 | + /// Census-only: the mirror of [`PlaneAlloc::PadZero`] -- zero the true | ||
| 21923 | + /// extent, leave the padded tail uninitialised. | ||
| 21924 | + ExtZero, | ||
| 21925 | +} | ||
| 21926 | + | ||
| 21927 | +/// `EC_AV1_PLANE_ALLOC`'s arm. Defaults to [`PlaneAlloc::Zeroed`], the shipped | ||
| 21928 | +/// closure; an unrecognised value is the default too, so a typo degrades to the | ||
| 21929 | +/// safe arm rather than back to the `unsafe` one. | ||
| 21930 | +fn plane_alloc() -> PlaneAlloc { | ||
| 21931 | + static ARM: std::sync::LazyLock<PlaneAlloc> = std::sync::LazyLock::new(|| { | ||
| 21932 | + match crate::envflags::var("EC_AV1_PLANE_ALLOC") | ||
| 21933 | + .ok() | ||
| 21934 | + .as_deref() | ||
| 21935 | + .map(str::trim) | ||
| 21936 | + { | ||
| 21937 | + Some("uninit") => PlaneAlloc::Uninit, | ||
| 21938 | + Some("fill") => PlaneAlloc::Fill, | ||
| 21939 | + Some("padzero") => PlaneAlloc::PadZero, | ||
| 21940 | + Some("extzero") => PlaneAlloc::ExtZero, | ||
| 21941 | + _ => PlaneAlloc::Zeroed, | ||
| 21942 | + } | ||
| 21943 | + }); | ||
| 21944 | + *ARM | ||
| 21945 | +} | ||
| 21946 | + | ||
| 21947 | +/// Zeroes a plane's PADDED tail -- the SB-aligned coding surface's invented | ||
| 21948 | +/// rows and columns outside `true_width` x `true_height` -- and leaves the | ||
| 21949 | +/// true extent alone. [`PlaneAlloc::PadZero`] only. | ||
| 21950 | +fn zero_pad(v: &mut [u16], width: usize, height: usize, true_width: usize, true_height: usize) { | ||
| 21951 | + for row in 0..height { | ||
| 21952 | + let base = row * width; | ||
| 21953 | + let first = if row < true_height { true_width } else { 0 }; | ||
| 21954 | + v[base + first..base + width].fill(0); | ||
| 21955 | + } | ||
| 21956 | +} | ||
| 21957 | + | ||
| 21958 | +/// Zeroes a plane's TRUE EXTENT and leaves the padded tail alone -- the mirror | ||
| 21959 | +/// of [`zero_pad`]. [`PlaneAlloc::ExtZero`] only. | ||
| 21960 | +fn zero_extent(v: &mut [u16], width: usize, true_width: usize, true_height: usize) { | ||
| 21961 | + for row in 0..true_height { | ||
| 21962 | + let base = row * width; | ||
| 21963 | + v[base..base + true_width].fill(0); | ||
| 21964 | + } | ||
| 21965 | +} | ||
| 21966 | + | ||
| 21967 | +/// A frame plane's own backing store, `n` samples. | ||
| 21968 | +/// | ||
| 21969 | +/// `true_width`/`true_height` are the plane's decodable extent in its own | ||
| 21970 | +/// units; `width`/`height` the block-aligned coding surface it is carved from | ||
| 21971 | +/// (`cols32 * 32`, so at most 31 px of margin per axis). They are what | ||
| 21972 | +/// [`zero_pad`]/[`zero_extent`] need and what the pad census reports against; | ||
| 21973 | +/// [`PlaneAlloc::Zeroed`] reads none of them. | ||
| 21974 | +/// | ||
| 21975 | +/// # WHAT CAN BE READ BEFORE IT IS WRITTEN -- the region list | ||
| 21976 | +/// | ||
| 21977 | +/// The premise an earlier revision of this comment carried -- "the SB-padded | ||
| 21978 | +/// surface is written sample-for-sample by the tile walk's reconstruction | ||
| 21979 | +/// before anything reads it" -- is RETRACTED by measurement | ||
| 21980 | +/// (`lanes/unwritten-dep.report.md` §12). What replaces it is this list, which | ||
| 21981 | +/// is checkable where a premise is not. TWO disjoint regions of the allocation | ||
| 21982 | +/// can hold a sample no block wrote: | ||
| 21983 | +/// | ||
| 21984 | +/// 1. THE PADDED TAIL -- every sample outside `true_width` x `true_height`, out | ||
| 21985 | +/// to the block-aligned surface. Unwritten BY CONSTRUCTION: no block lands | ||
| 21986 | +/// on it. Measured over all 128 committed fixtures at the pre-deblock point: | ||
| 21987 | +/// **4,676,128 unwritten of 22,787,296 scanned tail samples (20.5%)**, on 38 | ||
| 21988 | +/// fixtures. It is also **not read**: valgrind memcheck over the same 128 | ||
| 21989 | +/// fixtures, on the `uninit` arm, reports ZERO uninitialised-value uses -- | ||
| 21990 | +/// and the instrument is shown live by a deliberate tail read, which | ||
| 21991 | +/// produces 12 errors from 4 contexts (`lanes/av1uballoc.report.md` §2.4). | ||
| 21992 | +/// 2. THE TRUE EXTENT -- a sample inside `true_width` x `true_height` that the | ||
| 21993 | +/// tile walk skipped. This is where the withdrawn 224-sample demonstration | ||
| 21994 | +/// sat (`440_request_is_422`, U/V rows 36..63, whole 4x4 groups). Measured | ||
| 21995 | +/// over the same 127 fixtures at the pre-deblock point: **0 unwritten of | ||
| 21996 | +/// 1,466,581,280 scanned**, and 0 again at the output point. The one fixture | ||
| 21997 | +/// that demonstrated it is REFUSED on main, so nothing current reaches | ||
| 21998 | +/// region 2. | ||
| 21793 | /// | 21999 | /// |
| 21794 | -/// This comment previously claimed the SB-padded surface "is written | 22000 | +/// 3. THE WHOLE BUFFER, read-then-overwritten -- `pix_write` (`decode.rs:22073`, |
| 21795 | -/// sample-for-sample by the tile walk's reconstruction before anything reads | 22001 | +/// called at 22294/22450/39014/39029) takes the destination sample's own |
| 21796 | -/// it", and cited the sentinel gate as proof. **That claim is RETRACTED by | 22002 | +/// value as its `prev` argument, so on the first write to each sample it |
| 21797 | -/// measurement.** The basis for the retraction is THIS LANE's own, not | 22003 | +/// READS the initial content. Unlike regions 1 and 2 this one FIRES on |
| 21798 | -/// second-hand: on `440_request_is_422` an exact u16 whole-plane census at the | 22004 | +/// every fixture and every store -- and neither census can see it, because |
| 21799 | -/// pre-deblock point finds **112 unwritten samples per chroma plane, 224 total** | 22005 | +/// `prev` is consumed only inside `if *PIXPROBE_ON`, so it never reaches a |
| 21800 | -/// (U and V, 28 whole 4x4 groups each, rows 36..63) in a frame that is SHOWN | 22006 | +/// branch or a syscall. Confirmed: a DEBUG build under memcheck on the |
| 21801 | -/// (`Key show=true`) and whose samples the caller receives. Uninitialised memory | 22007 | +/// `uninit` arm still reports 0 errors. It does not affect output, and it is |
| 21802 | -/// that reaches the caller was read, or the read that produced it was. That is | 22008 | +/// deleted by the shipped closure along with everything else. |
| 21803 | -/// the UB, and it needs no hash-variation claim to stand. | ||
| 21804 | /// | 22009 | /// |
| 21805 | -/// A hash-variation observation also exists -- five plain runs of the same | 22010 | +/// The readers that could reach regions 1 and 2 are enumerated in |
| 21806 | -/// witness giving two different output hashes (`lanes/av1unwritten.report.md`), | 22011 | +/// `lanes/av1uballoc.report.md` §2; all of them clamp to `true_width`/ |
| 21807 | -/// which would point the same way -- but it is SECOND-HAND and was NOT | 22012 | +/// `true_height`, which is why region 1 never fires, and none of them is |
| 21808 | -/// reproduced here: five plain runs on `8d6998d7` gave one hash | 22013 | +/// reached on a current fixture, which is why region 2 does not either. |
| 21809 | -/// (`a761118c8dd5c8d0`, `lanes/unwritten-dep.report.md` §10). It is not relied | ||
| 21810 | -/// on, and the ambient content a run happens to receive is machine-dependent, | ||
| 21811 | -/// so a stable value on one host and a varying one on another would be the same | ||
| 21812 | -/// defect either way. The 224-sample census is the basis; the hashes are aside. | ||
| 21813 | /// | 22014 | /// |
| 21814 | -/// WHAT IS ACTUALLY ESTABLISHED, and it is weaker: | 22015 | +/// Those three measurements say no read of the initial content is reachable |
| 22016 | +/// from today's corpus. That is a statement about today's corpus, NOT a | ||
| 22017 | +/// licence for the `unsafe` below: a hostile file picks its own subsize values, | ||
| 22018 | +/// and the refusal that closes region 2 lives in the tile walk, not here -- | ||
| 22019 | +/// which is why it is a refusal and not a proof. So the shipped closure is | ||
| 22020 | +/// [`PlaneAlloc::Zeroed`] (+0.84% at 4K and -1.63% at 1080p, measured -- | ||
| 22021 | +/// `lanes/av1uballoc.report.md` §1), and the `unsafe` is reachable ONLY from | ||
| 22022 | +/// the `uninit`, `padzero` and `extzero` arms. | ||
| 21815 | /// | 22023 | /// |
| 21816 | -/// * The sentinel gate ([`census_unwritten_final`], | 22024 | +/// ONE ORDERING CONSTRAINT on the two census arms, because it changes what |
| 21817 | -/// `the_frame_the_caller_receives_carries_no_unwritten_plane_sample`) proves | 22025 | +/// they can be used for: the sentinel check comes FIRST, so |
| 21818 | -/// that no sample the tile walk never wrote SURVIVES into the frame the caller | 22026 | +/// [`PlaneAlloc::PadZero`] and [`PlaneAlloc::ExtZero`] never run while |
| 21819 | -/// receives, on the corpus measured. **It counts at the OUTPUT POINT ONLY -- | 22027 | +/// `EC_AV1_PLANE_SENTINEL` is set -- and that flag is what both census |
| 21820 | -/// one census, one scan.** The pre-deblock census ([`census_unwritten`], | 22028 | +/// functions require (each returns early when it is off). The census arms are |
| 21821 | -/// `take_unwritten_samples` / `take_census_scanned`) is a DIFFERENT instrument | 22029 | +/// therefore meaningful only under **memcheck with the sentinel OFF**, where |
| 21822 | -/// and has NO committed reader anywhere in the crate on `main`, so it backs | 22030 | +/// the zeroed/uninitialised split between the two regions is exactly what |
| 21823 | -/// nothing here; an earlier revision of this comment credited the gate with | 22031 | +/// memcheck keys on. The order stays as it is: moving the sentinel check below |
| 21824 | -/// both, which would have told a reviewer the premise is covered by two scans | 22032 | +/// the match would let the region census scan a buffer the sentinel never |
| 21825 | -/// when only one exists. It is measured SURVIVAL, not reads. | 22033 | +/// poisoned, which is the one thing it cannot recover from. |
| 21826 | -/// * It does NOT prove "every sample is written before it is read". A sample read | ||
| 21827 | -/// as a prediction or filter neighbour and overwritten a moment later is | ||
| 21828 | -/// invisible to that count. **No such read has been observed, and no | ||
| 21829 | -/// instrument here measures for one.** | ||
| 21830 | -/// * On `main` = `e45cc748` the one path where a read was demonstrated is | ||
| 21831 | -/// UNREACHABLE: lane/av1unwritten refuses the subsize before descending. | ||
| 21832 | /// | 22034 | /// |
| 21833 | -/// Honest status: a read-before-write is DEMONSTRATED on a path that is now | 22035 | +/// What IS sound and unchanged in that block: `u16` has no invalid bit patterns |
| 21834 | -/// refused, UNMEASURED on every other path, and this `unsafe` is sound only under | 22036 | +/// and no `Drop`, and the capacity was just reserved, so the vector validly |
| 21835 | -/// the unproven "written before read" premise. Filed as an open UB-class item | 22037 | +/// owns `n` slots. Creating a `Vec` over uninitialised memory is not itself |
| 21836 | -/// (`lanes/unwritten-dep.report.md` §12) with two closures: (a) zero the | 22038 | +/// UB -- a READ of a slot in region 1, region 2 or region 3 is. |
| 21837 | -/// allocation -- the safe default, at the ~3% this removed; or (b) an instrument | 22039 | +fn fresh_plane( |
| 21838 | -/// counting reads-before-write per sample, so the premise can be proved rather | 22040 | + n: usize, |
| 21839 | -/// than assumed. | 22041 | + true_width: usize, |
| 21840 | -fn fresh_plane(n: usize) -> Vec<u16> { | 22042 | + true_height: usize, |
| 22043 | + width: usize, | ||
| 22044 | + height: usize, | ||
| 22045 | +) -> Vec<u16> { | ||
| 21841 | if plane_sentinel_on() { | 22046 | if plane_sentinel_on() { |
| 21842 | - return vec![PLANE_SENTINEL; n]; | 22047 | + return vec![plane_poison(); n]; |
| 22048 | + } | ||
| 22049 | + match plane_alloc() { | ||
| 22050 | + PlaneAlloc::Zeroed => return vec![0u16; n], | ||
| 22051 | + PlaneAlloc::Fill => { | ||
| 22052 | + let mut v: Vec<u16> = Vec::with_capacity(n); | ||
| 22053 | + v.resize(n, 0); | ||
| 22054 | + return v; | ||
| 22055 | + } | ||
| 22056 | + PlaneAlloc::Uninit | PlaneAlloc::PadZero | PlaneAlloc::ExtZero => {} | ||
| 21843 | } | 22057 | } |
| 21844 | let mut v: Vec<u16> = Vec::with_capacity(n); | 22058 | let mut v: Vec<u16> = Vec::with_capacity(n); |
| 21845 | - // SAFETY, PARTIAL -- the premise is NOT established; see the block comment | 22059 | + // SAFETY: OWNING `n` uninitialised `u16` slots is sound (`u16` has no |
| 21846 | - // above ("THE `unsafe` BELOW IS NOT FULLY JUSTIFIED"). | 22060 | + // invalid bit patterns and no `Drop`, and the capacity was just reserved). |
| 21847 | - // | 22061 | + // A READ of a slot in region 1, region 2 or region 3 above would not be, |
| 21848 | - // What IS sound: `u16` has no invalid bit patterns and no `Drop`, and the | 22062 | + // which is why the shipped arm returns above and never reaches here: this |
| 21849 | - // capacity was just reserved, so the vector owns `n` slots that are valid to | 22063 | + // block is reachable only under `EC_AV1_PLANE_ALLOC=uninit|padzero|extzero` |
| 21850 | - // OWN. Creating a `Vec` over uninitialised memory is not itself UB. | 22064 | + // -- exactly the arms `plane_alloc()` lets fall through. `fill` is NOT one |
| 21851 | - // | 22065 | + // of them (it returns early at the `resize`), and an UNRECOGNISED value is |
| 21852 | - // What is NOT sound, and is the reason this is a filed item rather than a | 22066 | + // not either: `plane_alloc()` maps it to `Zeroed`, so a typo picks the safe |
| 21853 | - // settled one: reading an uninitialised `u16` IS UB, and the only thing that | 22067 | + // arm. The two region counts and the memcheck sweep are what make those |
| 21854 | - // makes the reads sound is the premise that reconstruction writes every | 22068 | + // arms' results readable; re-run them before believing a new "0". |
| 21855 | - // sample before any read. That premise was RETRACTED by measurement (224 | ||
| 21856 | - // unwritten samples, output varying with initial content) on a path that is | ||
| 21857 | - // now refused, and is UNMEASURED everywhere else. The sentinel gate measures | ||
| 21858 | - // survival at the output point, not reads. The pre-deblock census is a | ||
| 21859 | - // separate instrument with no committed reader on main, so it adds nothing | ||
| 21860 | - // here. So this `unsafe` is sound under a premise no current instrument | ||
| 21861 | - // proves. | ||
| 21862 | #[allow(unsafe_code)] | 22069 | #[allow(unsafe_code)] |
| 21863 | unsafe { | 22070 | unsafe { |
| 21864 | v.set_len(n); | 22071 | v.set_len(n); |
| 21865 | } | 22072 | } |
| 22073 | + match plane_alloc() { | ||
| 22074 | + PlaneAlloc::PadZero => zero_pad(&mut v, width, height, true_width, true_height), | ||
| 22075 | + PlaneAlloc::ExtZero => zero_extent(&mut v, width, true_width, true_height), | ||
| 22076 | + _ => {} | ||
| 22077 | + } | ||
| 21866 | v | 22078 | v |
| 21867 | } | 22079 | } |
| 21868 | 22080 | ||
| @@ -35908,7 +36120,13 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 35908 | let (width, height) = (cols32 as usize * BLOCK, rows32 as usize * BLOCK); | 36120 | let (width, height) = (cols32 as usize * BLOCK, rows32 as usize * BLOCK); |
| 35909 | 36121 | ||
| 35910 | let mut y = PlaneBuf { | 36122 | let mut y = PlaneBuf { |
| 35911 | - data: std::borrow::Cow::Owned(fresh_plane(width * height)), | 36123 | + data: std::borrow::Cow::Owned(fresh_plane( |
| 36124 | + width * height, | ||
| 36125 | + true_width, | ||
| 36126 | + true_height, | ||
| 36127 | + width, | ||
| 36128 | + height, | ||
| 36129 | + )), | ||
| 35912 | width, | 36130 | width, |
| 35913 | height, | 36131 | height, |
| 35914 | true_width, | 36132 | true_width, |
| @@ -35922,7 +36140,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 35922 | let (cw, ch) = (width >> ss_x(fctx), height >> ss_y(fctx)); | 36140 | let (cw, ch) = (width >> ss_x(fctx), height >> ss_y(fctx)); |
| 35923 | let (ctw, cth) = (true_width >> ss_x(fctx), true_height >> ss_y(fctx)); | 36141 | let (ctw, cth) = (true_width >> ss_x(fctx), true_height >> ss_y(fctx)); |
| 35924 | let mut u = PlaneBuf { | 36142 | let mut u = PlaneBuf { |
| 35925 | - data: std::borrow::Cow::Owned(fresh_plane(cw * ch)), | 36143 | + data: std::borrow::Cow::Owned(fresh_plane(cw * ch, ctw, cth, cw, ch)), |
| 35926 | width: cw, | 36144 | width: cw, |
| 35927 | height: ch, | 36145 | height: ch, |
| 35928 | true_width: ctw, | 36146 | true_width: ctw, |
| @@ -35934,7 +36152,7 @@ pub(crate) fn decode_key_frame_tile_with_cdfs( | |||
| 35934 | plane: 1, | 36152 | plane: 1, |
| 35935 | }; | 36153 | }; |
| 35936 | let mut v = PlaneBuf { | 36154 | let mut v = PlaneBuf { |
| 35937 | - data: std::borrow::Cow::Owned(fresh_plane(cw * ch)), | 36155 | + data: std::borrow::Cow::Owned(fresh_plane(cw * ch, ctw, cth, cw, ch)), |
| 35938 | width: cw, | 36156 | width: cw, |
| 35939 | height: ch, | 36157 | height: ch, |
| 35940 | true_width: ctw, | 36158 | true_width: ctw, |
| @@ -53682,7 +53900,13 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 53682 | let (width, height) = (cols as usize * BLOCK, rows as usize * BLOCK); | 53900 | let (width, height) = (cols as usize * BLOCK, rows as usize * BLOCK); |
| 53683 | 53901 | ||
| 53684 | let mut y = PlaneBuf { | 53902 | let mut y = PlaneBuf { |
| 53685 | - data: std::borrow::Cow::Owned(fresh_plane(width * height)), | 53903 | + data: std::borrow::Cow::Owned(fresh_plane( |
| 53904 | + width * height, | ||
| 53905 | + true_width, | ||
| 53906 | + true_height, | ||
| 53907 | + width, | ||
| 53908 | + height, | ||
| 53909 | + )), | ||
| 53686 | width, | 53910 | width, |
| 53687 | height, | 53911 | height, |
| 53688 | true_width, | 53912 | true_width, |
| @@ -53696,7 +53920,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 53696 | let (cw, ch) = (width >> ss_x(fctx), height >> ss_y(fctx)); | 53920 | let (cw, ch) = (width >> ss_x(fctx), height >> ss_y(fctx)); |
| 53697 | let (ctw, cth) = (true_width >> ss_x(fctx), true_height >> ss_y(fctx)); | 53921 | let (ctw, cth) = (true_width >> ss_x(fctx), true_height >> ss_y(fctx)); |
| 53698 | let mut u = PlaneBuf { | 53922 | let mut u = PlaneBuf { |
| 53699 | - data: std::borrow::Cow::Owned(fresh_plane(cw * ch)), | 53923 | + data: std::borrow::Cow::Owned(fresh_plane(cw * ch, ctw, cth, cw, ch)), |
| 53700 | width: cw, | 53924 | width: cw, |
| 53701 | height: ch, | 53925 | height: ch, |
| 53702 | true_width: ctw, | 53926 | true_width: ctw, |
| @@ -53708,7 +53932,7 @@ pub(crate) fn decode_inter_frame_tile_with_cdfs( | |||
| 53708 | plane: 1, | 53932 | plane: 1, |
| 53709 | }; | 53933 | }; |
| 53710 | let mut v = PlaneBuf { | 53934 | let mut v = PlaneBuf { |
| 53711 | - data: std::borrow::Cow::Owned(fresh_plane(cw * ch)), | 53935 | + data: std::borrow::Cow::Owned(fresh_plane(cw * ch, ctw, cth, cw, ch)), |
| 53712 | width: cw, | 53936 | width: cw, |
| 53713 | height: ch, | 53937 | height: ch, |
| 53714 | true_width: ctw, | 53938 | true_width: ctw, |
crates/ec-av1/src/stream.rsmodified+233 -0
| @@ -48567,6 +48567,239 @@ exit 0 | |||
| 48567 | println!("UWDEP_CENSUS {n} frames={} scanned={scanned}", frames.len()); | 48567 | println!("UWDEP_CENSUS {n} frames={} scanned={scanned}", frames.len()); |
| 48568 | } | 48568 | } |
| 48569 | 48569 | ||
| 48570 | + /// lane-av1uballoc: the frame the caller receives does not depend on what | ||
| 48571 | + /// the plane buffer held before the decode wrote it. | ||
| 48572 | + /// | ||
| 48573 | + /// Four runs of the same fixtures, each in its own process (the fill and | ||
| 48574 | + /// the alloc closure are both process-constant env reads -- see | ||
| 48575 | + /// [`crate::envflags`] -- and this crate forbids `set_var`), must agree on | ||
| 48576 | + /// one hash per fixture: | ||
| 48577 | + /// | ||
| 48578 | + /// * `EC_AV1_PLANE_SENTINEL=0xDEAD` and `=0xBEEF` -- two DIFFERENT | ||
| 48579 | + /// impossible values for the same buffer. This is the arm that can | ||
| 48580 | + /// actually FAIL: if any reader's value reaches the picture, changing the | ||
| 48581 | + /// poison changes the output. Equal hashes are a statement about a READ, | ||
| 48582 | + /// which is what the `unsafe` in [`decode::fresh_plane`] needs and what no | ||
| 48583 | + /// census in the crate measures. | ||
| 48584 | + /// * the sentinel OFF with `EC_AV1_PLANE_ALLOC=uninit` and `=zeroed` -- the | ||
| 48585 | + /// status quo and the shipped closure, which must agree with each other | ||
| 48586 | + /// and with the poisoned runs. This is the "same with the sentinel off" | ||
| 48587 | + /// arm; on its own it is weak (the allocator may hand out the same | ||
| 48588 | + /// ambient bytes twice) and is here as the join between the two worlds. | ||
| 48589 | + /// | ||
| 48590 | + /// NON-VACUITY, first and synthetic: [`allocdet_synthetic`] hashes two | ||
| 48591 | + /// pictures that differ in ONE sample and asserts the hashes DIFFER. A hash | ||
| 48592 | + /// that cannot see a one-sample difference would make every equality below | ||
| 48593 | + /// vacuous, and it is the failure mode a "0 errors" style result has. | ||
| 48594 | + /// Second: every arm must report `frames>0`, so a child that decoded | ||
| 48595 | + /// nothing cannot agree with another child that decoded nothing. | ||
| 48596 | + #[test] | ||
| 48597 | + fn the_frame_does_not_depend_on_the_plane_buffers_initial_content() { | ||
| 48598 | + const NAME: &str = "the_frame_does_not_depend_on_the_plane_buffers_initial_content"; | ||
| 48599 | + let _gate_lock = lock_gate_counters(); | ||
| 48600 | + // Kept SMALL on purpose: the whole gate is 4 child processes x this | ||
| 48601 | + // list, and the suite runs it in a DEBUG build. A first revision used | ||
| 48602 | + // the 1920x792 film fixtures here and took 252 s, which is not a gate | ||
| 48603 | + // anyone keeps. These ten cover every shape the region list names -- | ||
| 48604 | + // 4:2:2 (12-bit key, inter, sb128 intrabc, 17-frame odd-size), 4:4:4 | ||
| 48605 | + // (lossless sb64, intrabc rect4, 128-root mu), a padded odd size, an | ||
| 48606 | + // off-tile chroma walk, and superres+CDEF+LR -- for ~1.3 s per arm. | ||
| 48607 | + const FIXTURES: &[&str] = &[ | ||
| 48608 | + "s422_12bit_160x128", | ||
| 48609 | + "422_inter_160x128_3f", | ||
| 48610 | + "422_intrabc_sb128_strip", | ||
| 48611 | + "s422_352x242_10b", | ||
| 48612 | + "ll444_sb64_1to4_lossless", | ||
| 48613 | + "444_intrabc_rect4_witness", | ||
| 48614 | + "444_intra_in_inter_128root_mu_chroma", | ||
| 48615 | + "svt1-split-tx-pin", | ||
| 48616 | + "mix176_offtile_chroma_clip", | ||
| 48617 | + "superres_kf_cdef_lr_64x64", | ||
| 48618 | + ]; | ||
| 48619 | + | ||
| 48620 | + let (a, b) = allocdet_synthetic(); | ||
| 48621 | + assert_ne!( | ||
| 48622 | + a, b, | ||
| 48623 | + "{NAME}: the content hash returned the same value for two pictures differing in one \ | ||
| 48624 | + sample, so every equality below is vacuous -- this gate would pass on any decoder, \ | ||
| 48625 | + including one that returns garbage (class: hash-cannot-see-content)" | ||
| 48626 | + ); | ||
| 48627 | + | ||
| 48628 | + let arms: [(&str, Option<&str>, &str); 4] = [ | ||
| 48629 | + ("poison-dead", Some("0xDEAD"), "uninit"), | ||
| 48630 | + ("poison-beef", Some("0xBEEF"), "uninit"), | ||
| 48631 | + ("sentinel-off-uninit", None, "uninit"), | ||
| 48632 | + ("alloc-zeroed", None, "zeroed"), | ||
| 48633 | + ]; | ||
| 48634 | + let mut baseline: Option<Vec<(String, usize, u64)>> = None; | ||
| 48635 | + for (label, poison, alloc) in arms { | ||
| 48636 | + let rows = allocdet_child(FIXTURES, poison, alloc); | ||
| 48637 | + assert_eq!( | ||
| 48638 | + rows.len(), | ||
| 48639 | + FIXTURES.len(), | ||
| 48640 | + "{NAME}: the {label} arm reported {} of {} fixtures -- a run that decoded \ | ||
| 48641 | + nothing can agree with another run that decoded nothing", | ||
| 48642 | + rows.len(), | ||
| 48643 | + FIXTURES.len() | ||
| 48644 | + ); | ||
| 48645 | + for (f, frames, _) in &rows { | ||
| 48646 | + assert!( | ||
| 48647 | + *frames > 0, | ||
| 48648 | + "{NAME}: the {label} arm decoded 0 frames of {f}; the hashes it compared are \ | ||
| 48649 | + over nothing" | ||
| 48650 | + ); | ||
| 48651 | + } | ||
| 48652 | + match &baseline { | ||
| 48653 | + None => baseline = Some(rows), | ||
| 48654 | + Some(first) => { | ||
| 48655 | + for (i, (f, frames, h)) in rows.iter().enumerate() { | ||
| 48656 | + let (bf, bframes, bh) = &first[i]; | ||
| 48657 | + assert_eq!( | ||
| 48658 | + bf, f, | ||
| 48659 | + "{NAME}: arm {label} reported fixture {f} where the \ | ||
| 48660 | + baseline reported {bf} -- the arms are not comparable" | ||
| 48661 | + ); | ||
| 48662 | + assert_eq!( | ||
| 48663 | + bframes, frames, | ||
| 48664 | + "{NAME}: {f} decoded {frames} frames under \ | ||
| 48665 | + {label} and {bframes} under the baseline arm" | ||
| 48666 | + ); | ||
| 48667 | + assert_eq!( | ||
| 48668 | + bh, h, | ||
| 48669 | + "{NAME}: {f} decoded to a DIFFERENT picture depending on what the \ | ||
| 48670 | + plane buffer held before the decode wrote it -- {label} gave {h:016x}, \ | ||
| 48671 | + the baseline arm gave {bh:016x}. A read of uninitialised memory \ | ||
| 48672 | + reaches the caller's frame (see the SAFETY comment on \ | ||
| 48673 | + decode::fresh_plane)." | ||
| 48674 | + ); | ||
| 48675 | + } | ||
| 48676 | + } | ||
| 48677 | + } | ||
| 48678 | + } | ||
| 48679 | + } | ||
| 48680 | + | ||
| 48681 | + /// Runs [`allocdet_child_decode`] in a fresh process and parses its | ||
| 48682 | + /// `ALLOCDET <fixture> frames=<n> hash=<hex>` lines into | ||
| 48683 | + /// `(fixture, frames, hash)` in FIXTURES order. | ||
| 48684 | + fn allocdet_child( | ||
| 48685 | + fixtures: &[&str], | ||
| 48686 | + poison: Option<&str>, | ||
| 48687 | + alloc: &str, | ||
| 48688 | + ) -> Vec<(String, usize, u64)> { | ||
| 48689 | + const NAME: &str = "the_frame_does_not_depend_on_the_plane_buffers_initial_content"; | ||
| 48690 | + let exe = std::env::current_exe().expect("test binary path"); | ||
| 48691 | + let mut cmd = std::process::Command::new(exe); | ||
| 48692 | + cmd.args([ | ||
| 48693 | + "--exact", | ||
| 48694 | + "stream::tests::allocdet_child_decode", | ||
| 48695 | + "--nocapture", | ||
| 48696 | + ]) | ||
| 48697 | + .env("ALLOCDET_FIXTURES", fixtures.join(",")) | ||
| 48698 | + .env("EC_AV1_PLANE_ALLOC", alloc) | ||
| 48699 | + .env_remove("ALLOCDET_SYNTHETIC"); | ||
| 48700 | + match poison { | ||
| 48701 | + Some(p) => cmd.env("EC_AV1_PLANE_SENTINEL", p), | ||
| 48702 | + None => cmd.env_remove("EC_AV1_PLANE_SENTINEL"), | ||
| 48703 | + }; | ||
| 48704 | + let out = cmd.output().expect("running the allocdet child"); | ||
| 48705 | + let text = format!( | ||
| 48706 | + "{}{}", | ||
| 48707 | + String::from_utf8_lossy(&out.stdout), | ||
| 48708 | + String::from_utf8_lossy(&out.stderr), | ||
| 48709 | + ); | ||
| 48710 | + let mut rows = Vec::new(); | ||
| 48711 | + for f in fixtures { | ||
| 48712 | + let line = text | ||
| 48713 | + .lines() | ||
| 48714 | + .find(|l| l.starts_with(&format!("ALLOCDET {f} "))) | ||
| 48715 | + .unwrap_or_else(|| { | ||
| 48716 | + panic!( | ||
| 48717 | + "{NAME}: the child reported nothing for {f} (child said: {:?})", | ||
| 48718 | + text.trim() | ||
| 48719 | + ) | ||
| 48720 | + }); | ||
| 48721 | + let mut parts = line.split_whitespace(); | ||
| 48722 | + assert_eq!(parts.next(), Some("ALLOCDET")); | ||
| 48723 | + assert_eq!(parts.next(), Some(*f)); | ||
| 48724 | + let frames = parts | ||
| 48725 | + .find_map(|p| p.strip_prefix("frames=")) | ||
| 48726 | + .and_then(|v| v.parse().ok()) | ||
| 48727 | + .unwrap_or_else(|| panic!("{NAME}: no frame count in {line:?}")); | ||
| 48728 | + let hash = parts | ||
| 48729 | + .find_map(|p| p.strip_prefix("hash=")) | ||
| 48730 | + .and_then(|v| u64::from_str_radix(v, 16).ok()) | ||
| 48731 | + .unwrap_or_else(|| panic!("{NAME}: no hash in {line:?}")); | ||
| 48732 | + rows.push(((*f).to_string(), frames, hash)); | ||
| 48733 | + } | ||
| 48734 | + rows | ||
| 48735 | + } | ||
| 48736 | + | ||
| 48737 | + /// The child half of | ||
| 48738 | + /// [`the_frame_does_not_depend_on_the_plane_buffers_initial_content`]: | ||
| 48739 | + /// decodes every fixture named in `ALLOCDET_FIXTURES` and prints one | ||
| 48740 | + /// `ALLOCDET` line each. | ||
| 48741 | + /// | ||
| 48742 | + /// With `ALLOCDET_SYNTHETIC` set it instead prints the two hashes the | ||
| 48743 | + /// non-vacuity control compares -- two pictures differing in ONE sample -- | ||
| 48744 | + /// and decodes nothing. | ||
| 48745 | + #[test] | ||
| 48746 | + fn allocdet_child_decode() { | ||
| 48747 | + if std::env::var_os("ALLOCDET_SYNTHETIC").is_some() { | ||
| 48748 | + let (a, b) = allocdet_synthetic(); | ||
| 48749 | + println!("ALLOCDET_SYNTHETIC {a:016x} {b:016x}"); | ||
| 48750 | + return; | ||
| 48751 | + } | ||
| 48752 | + let list = std::env::var("ALLOCDET_FIXTURES").expect("ALLOCDET_FIXTURES"); | ||
| 48753 | + let mut hash = 0xcbf2_9ce4_8422_2325u64; | ||
| 48754 | + for fixture in list.split(',').filter(|s| !s.is_empty()) { | ||
| 48755 | + let path = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) | ||
| 48756 | + .join(format!("fixtures/{fixture}.obu")); | ||
| 48757 | + let stream = | ||
| 48758 | + std::fs::read(&path).unwrap_or_else(|e| panic!("reading {}: {e}", path.display())); | ||
| 48759 | + let mut frames = 0usize; | ||
| 48760 | + decode_stream_with(&stream, |pic, _idx, shown| { | ||
| 48761 | + if !shown { | ||
| 48762 | + return Ok(()); | ||
| 48763 | + } | ||
| 48764 | + frames += 1; | ||
| 48765 | + for p in [&pic.y, &pic.u, &pic.v] { | ||
| 48766 | + for &s in p.iter() { | ||
| 48767 | + for b in s.to_le_bytes() { | ||
| 48768 | + hash ^= u64::from(b); | ||
| 48769 | + hash = hash.wrapping_mul(0x0000_0100_0000_01b3); | ||
| 48770 | + } | ||
| 48771 | + } | ||
| 48772 | + } | ||
| 48773 | + Ok(()) | ||
| 48774 | + }) | ||
| 48775 | + .unwrap_or_else(|e| panic!("{fixture} refused: {e}")); | ||
| 48776 | + println!("ALLOCDET {fixture} frames={frames} hash={hash:016x}"); | ||
| 48777 | + } | ||
| 48778 | + } | ||
| 48779 | + | ||
| 48780 | + /// Two pictures identical except for ONE sample of ONE plane, hashed by the | ||
| 48781 | + /// same FNV-1a the child uses. Equal values here would make the gate's | ||
| 48782 | + /// equalities vacuous, so it is asserted to differ. | ||
| 48783 | + fn allocdet_synthetic() -> (u64, u64) { | ||
| 48784 | + const P: u64 = 0x0000_0100_0000_01b3; | ||
| 48785 | + let hash = |mut h: u64, samples: &[u16]| { | ||
| 48786 | + for &s in samples { | ||
| 48787 | + for b in s.to_le_bytes() { | ||
| 48788 | + h ^= u64::from(b); | ||
| 48789 | + h = h.wrapping_mul(P); | ||
| 48790 | + } | ||
| 48791 | + } | ||
| 48792 | + h | ||
| 48793 | + }; | ||
| 48794 | + let a = vec![128u16; 4096]; | ||
| 48795 | + let mut b = a.clone(); | ||
| 48796 | + b[2048] = 129; | ||
| 48797 | + ( | ||
| 48798 | + hash(0xcbf2_9ce4_8422_2325, &a), | ||
| 48799 | + hash(0xcbf2_9ce4_8422_2325, &b), | ||
| 48800 | + ) | ||
| 48801 | + } | ||
| 48802 | + | ||
| 48570 | /// lane-t900 r6: the 128-superblock INTER witness. | 48803 | /// lane-t900 r6: the 128-superblock INTER witness. |
| 48571 | /// `crates/ec-av1/fixtures/reelc_sb128_inter_witness.obu`, 177773 bytes, | 48804 | /// `crates/ec-av1/fixtures/reelc_sb128_inter_witness.obu`, 177773 bytes, |
| 48572 | /// sha256 `09d995946d27695ef4b7b1a24a4d7ad85f8e2c8176d58ee54e825efc061f9cbc`: | 48805 | /// sha256 `09d995946d27695ef4b7b1a24a4d7ad85f8e2c8176d58ee54e825efc061f9cbc`: |
lanes/av1uballoc.report.mdadded+414 -0
| @@ -0,0 +1,414 @@ | |||
| 1 | +# lane/av1uballoc — the plane allocation closure, decided with a number | ||
| 2 | + | ||
| 3 | +Started from base `2d8fa8a4`; **rebased onto `f01e9738` and re-measured there** | ||
| 4 | +(§7). Target: `crates/ec-av1/src/decode.rs`'s `fresh_plane` and the | ||
| 5 | +`unsafe { v.set_len(n) }` behind it. | ||
| 6 | + | ||
| 7 | +**Decision: ship closure (b), `vec![0u16; n]` (`alloc_zeroed`/`calloc`).** It | ||
| 8 | +costs **+0.84%** of decode wall time at 3840x2160 4:2:0 and **+0.81%** at | ||
| 9 | +3840x2160 4:2:2 (both ~6σ against a 6–10 ms run-to-run spread), and **−1.63%** | ||
| 10 | +at 1920x1080 — it is *faster* there, reproducibly. It removes the `unsafe` | ||
| 11 | +from every build that is not explicitly asking for a census arm. | ||
| 12 | + | ||
| 13 | +**No fixture on current main reaches an uninitialised read.** The reads-before- | ||
| 14 | +write census below found zero, by two independent instruments, over all 128 | ||
| 15 | +committed fixtures. The charter's stop condition did not fire. | ||
| 16 | + | ||
| 17 | +--- | ||
| 18 | + | ||
| 19 | +## 0. Two corrections to the charter before the numbers | ||
| 20 | + | ||
| 21 | +* **`EC_AV1_PERF*` does not exist** in this repository — not in `crates/ec-av1`, | ||
| 22 | + not anywhere. The real decode-timing instruments are `EC_AV1_TIMELINE` | ||
| 23 | + (`src/timeline.rs:1-13`, dumped by `stream.rs:1369`, read by | ||
| 24 | + `scripts/av1-timeline-report.py`) and `EC_AV1_WAVE_STATS`. Neither buckets | ||
| 25 | + decode into stages — they bucket a *frame's phases*, and the report script's | ||
| 26 | + own doc says the per-phase sums exceed `wall` by construction, so they must | ||
| 27 | + not be summed. Neither attributes a cost to an allocation, so this lane added | ||
| 28 | + `examples/alloc_timing.rs`, which times the `decode_stream_with` call and | ||
| 29 | + reads `minflt`/`majflt` from `/proc/self/stat` around it. It prints one | ||
| 30 | + machine-readable line per process, which is what makes the interleaved | ||
| 31 | + round-robin below possible. | ||
| 32 | + | ||
| 33 | +The closures are an **env arm inside the crate** (`EC_AV1_PLANE_ALLOC`), not a | ||
| 34 | +build flag, so all three share one binary, one allocator state and one machine. | ||
| 35 | +Three separate builds cannot make this comparison fair — the recycled-arena | ||
| 36 | +state, the page-cache state and the code layout all differ between them. | ||
| 37 | + | ||
| 38 | +--- | ||
| 39 | + | ||
| 40 | +## 1. The table | ||
| 41 | + | ||
| 42 | +`cargo run -p ec-av1 --release --example alloc_timing -- <stream>`, arms | ||
| 43 | +round-robined across processes so a drift hits every arm equally. Medians of 11 | ||
| 44 | +runs each (`n=11` below). Linux 7.2.7, 12 cores, glibc, default allocator, | ||
| 45 | +single-threaded decode (`EC_AV1_THREADS=1` is the crate default). | ||
| 46 | + | ||
| 47 | +### 3840x2160 4:2:0, 96 frames | ||
| 48 | + | ||
| 49 | +| arm | median ms | min ms | mean ms | stdev ms | Δ% | minflt | output hash | | ||
| 50 | +|---|---|---|---|---|---|---|---| | ||
| 51 | +| `uninit` — status quo, `set_len` | 6937.728 | 6926.888 | 6939.318 | 7.731 | +0.00 | 280 846 | `c93abb392857618d` | | ||
| 52 | +| `fill` — closure (a), explicit zero-fill | 7001.420 | 6992.227 | 7001.984 | 6.448 | **+0.92** | 215 336 | `c93abb392857618d` | | ||
| 53 | +| `zeroed` — closure (b), `alloc_zeroed` | 6995.727 | 6978.615 | 6995.769 | 10.201 | **+0.84** | 278 704 | `c93abb392857618d` | | ||
| 54 | + | ||
| 55 | +### 3840x2160 4:2:2, 48 frames | ||
| 56 | + | ||
| 57 | +| arm | median ms | min ms | mean ms | stdev ms | Δ% | minflt | output hash | | ||
| 58 | +|---|---|---|---|---|---|---|---| | ||
| 59 | +| `uninit` | 4709.657 | 4703.387 | 4716.928 | 16.443 | +0.00 | 204 348 | `1c8526888dc2285d` | | ||
| 60 | +| `fill` | 4750.184 | 4741.289 | 4751.697 | 7.264 | **+0.86** | 142 987 | `1c8526888dc2285d` | | ||
| 61 | +| `zeroed` | 4747.944 | 4740.307 | 4749.023 | 7.219 | **+0.81** | 202 410 | `1c8526888dc2285d` | | ||
| 62 | + | ||
| 63 | +### 1920x1080 4:2:0, 96 frames | ||
| 64 | + | ||
| 65 | +| arm | median ms | min ms | mean ms | stdev ms | Δ% | minflt | output hash | | ||
| 66 | +|---|---|---|---|---|---|---|---| | ||
| 67 | +| `uninit` | 1768.411 | 1767.167 | 1775.918 | 9.964 | +0.00 | 60 023 | `ba5f2444c2b60885` | | ||
| 68 | +| `fill` | 1735.265 | 1731.097 | 1742.735 | 21.224 | **−1.87** | 47 018 | `ba5f2444c2b60885` | | ||
| 69 | +| `zeroed` | 1739.516 | 1733.861 | 1743.644 | 10.109 | **−1.63** | 59 170 | `ba5f2444c2b60885` | | ||
| 70 | + | ||
| 71 | +**Every hash is identical within a stream.** The closure chosen moves not one | ||
| 72 | +output sample. | ||
| 73 | + | ||
| 74 | +### What the table says, and what it does not | ||
| 75 | + | ||
| 76 | +* **(b) is not the free lunch the arm's name advertises.** `zeroed` and `fill` | ||
| 77 | + land within 0.03 % of each other at every size. glibc hands a *recycled* | ||
| 78 | + arena block back from `calloc` with the same memset an explicit fill does; the | ||
| 79 | + "a page fault per page is the mechanism" story is wrong for a decoder that | ||
| 80 | + frees and re-allocates the same plane every frame. | ||
| 81 | +* **The cost is one extra pass over a buffer the decode immediately overwrites**: | ||
| 82 | + +55 ms over 96 frames of 24.9 MB ≈ 42 GB/s of extra write bandwidth. The | ||
| 83 | + `minflt` column is *not* the story — `fill` faults the fewest pages at 4K | ||
| 84 | + (215 k vs 281 k) and is still the slowest arm, so page-fault count does not | ||
| 85 | + explain the delta. | ||
| 86 | +* **The 1080p sign flip is real and reproducible** (two independent 11-run | ||
| 87 | + rounds: −1.59 %/−1.51 %, then −1.87 %/−1.63 %) and **is not explained here**. | ||
| 88 | + I am reporting the number, not a story for it. It is the one result a | ||
| 89 | + reviewer should re-run before trusting the 4K cost on their own hardware. | ||
| 90 | + | ||
| 91 | +--- | ||
| 92 | + | ||
| 93 | +## 2. Reads-before-write census — regions × readers × reachability | ||
| 94 | + | ||
| 95 | +### 2.1 The two regions | ||
| 96 | + | ||
| 97 | +`fresh_plane(n, true_width, true_height, width, height)` hands back `n = | ||
| 98 | +width * height` slots. `width` is `block_grid(mi_cols) * 32` and | ||
| 99 | +`true_width = mi_cols * 4`, so the plane is a **block-aligned coding surface** | ||
| 100 | +with up to 31 px of margin per axis. `true_width`/`true_height` is the decodable | ||
| 101 | +extent. That splits the allocation into two disjoint regions that can hold a | ||
| 102 | +sample no block wrote: | ||
| 103 | + | ||
| 104 | +| # | region | definition | can a reader reach it? | | ||
| 105 | +|---|---|---|---| | ||
| 106 | +| 1 | **padded tail** | everything outside `true_width × true_height`, out to `width × height` | in principle; **not in practice** — see §2.3 | | ||
| 107 | +| 2 | **true extent** | inside `true_width × true_height` that the tile walk skipped | yes — this is where the withdrawn 224-sample demonstration sat | | ||
| 108 | + | ||
| 109 | +The old `census_unwritten` scanned region 2 only, under a doc comment asserting | ||
| 110 | +*"past that is the padded coding surface's invented tail, which no decoder ever | ||
| 111 | +reads"*. That assertion is exactly what an unread tail looks like, so it was | ||
| 112 | +self-certifying. This lane scans both and counts them separately | ||
| 113 | +(`PAD_UNWRITTEN_SAMPLES` / `take_pad_unwritten_samples`), and the comment now | ||
| 114 | +says what was measured. | ||
| 115 | + | ||
| 116 | +### 2.2 The readers | ||
| 117 | + | ||
| 118 | +Line numbers are `main` = `2d8fa8a4`. | ||
| 119 | + | ||
| 120 | +| reader class | sites | reads the CURRENT frame? | clamps to true extent? | reachable on a current fixture? | | ||
| 121 | +|---|---|---|---|---| | ||
| 122 | +| intra prediction (neighbour edges, above/right/below/left) | `PlaneBuf::above/left/below/right_of`, `decode.rs:22059-22110` (`own_across = x + side.min(true_width - x)`, same down) | yes | **yes**, `saturating_sub(true_width/true_height)` plus `tile_x1/tile_y1` | no | | ||
| 123 | +| intra TX bound checks | `decode.rs:12630, 13007, 15179, 19411, 23202, 23736, 24428, 25031, 39153, 39341` (`if px >= true_width { continue }`) | yes | yes | no | | ||
| 124 | +| CfL (chroma-from-luma) | via the TX store paths above | yes (luma block region) | yes | no | | ||
| 125 | +| IntraBC / intrabc copy | `decode.rs:14451-14527, 15009-15074` | yes (the block's own luma) | yes | no | | ||
| 126 | +| intra-in-inter | `decode.rs:18266-18387, 23062-23095` | yes | yes | no | | ||
| 127 | +| deblock | `apply_deblock`, `decode.rs:33367-33370` (`tw = true_width.min(cw)`) | yes | yes | no | | ||
| 128 | +| CDEF | `cdef_gather(..., true_width, true_height, ...)`, `decode.rs:34397-34484` | yes | yes | no | | ||
| 129 | +| loop restoration | `restoration.rs:1053+`, driven with `true_width`/`true_height` (`decode.rs:35315-35319`) | yes | yes | no | | ||
| 130 | +| superres upscale | `superres.rs:100-240`, over the mi-aligned margin, cropped to `true_width` | yes | yes | no | | ||
| 131 | +| **inter prediction / MC / warp / OBMC / compound** | `decode.rs:40384-40386, 40399-40406, 42757-42761, 44560-44581` (all pass `true_width`/`true_height` of the REFERENCE plane) | **no — a different frame's buffer** | n/a | n/a | | ||
| 132 | +| reference-frame materialisation | the crop at `decode.rs:38480-38548` | copies the true extent only | yes | n/a | | ||
| 133 | +| `pix_write`'s `prev` argument — **the one unconditional read-before-write in the shipped source** | `decode.rs:22073` (fn), called at `22294`, `22450`, `39014`, `39029`, passing `*o` / the slot's own value | yes — reads the destination sample *before* overwriting it | no | **fires on every store, on every fixture — but is not observable.** See §2.5 | | ||
| 134 | + | ||
| 135 | +The load-bearing structural fact: **every current-frame reader clamps to | ||
| 136 | +`true_width`/`true_height`**, which is why region 1 never fires. The 224-sample | ||
| 137 | +defect of `lanes/unwritten-dep.report.md` was in region 2 and needed no | ||
| 138 | +clamp-bypass — it was the tile walk skipping samples, not a reader reaching | ||
| 139 | +past the edge. | ||
| 140 | + | ||
| 141 | +### 2.3 Region census — measurement | ||
| 142 | + | ||
| 143 | +`EC_AV1_PLANE_SENTINEL=1 decode_probe <fixture>`, summed over all 128 | ||
| 144 | +committed fixtures, both regions, at the **pre-deblock** point | ||
| 145 | +(`census_unwritten`, called at `decode.rs:38139` in | ||
| 146 | +`decode_key_frame_tile_with_cdfs` and `56507` in the inter path — after | ||
| 147 | +`flush_recon`, before `apply_deblock`): | ||
| 148 | + | ||
| 149 | +``` | ||
| 150 | +TOTAL extent_scanned=1,466,581,280 EXT_HOLE=0 | ||
| 151 | + pad_scanned = 22,787,296 PAD_HOLE=4,676,128 | ||
| 152 | +fixtures with a nonzero hole in either region: 38 | ||
| 153 | +``` | ||
| 154 | + | ||
| 155 | +* **Region 2 (true extent): 0 unwritten of 1.47 G scanned.** The withdrawn | ||
| 156 | + defect is gone from the current corpus, and the one fixture that | ||
| 157 | + demonstrated it is refused: | ||
| 158 | + `440_request_is_422` → `REFUSED: unsupported: AV1 tile (a block size 4x8, | ||
| 159 | + 8x16 or 16x4 (or 8x4 at 4:4:0) has no chroma plane block at this frame's | ||
| 160 | + subsampling mode …)` (`decode.rs:21643`). | ||
| 161 | +* **Region 1 (padded tail): 4.68 M unwritten of 22.8 M scanned (20.5 %)** on | ||
| 162 | + 38 fixtures — unwritten *by construction*, since no block lands there. This | ||
| 163 | + is the region whose "nobody reads it" claim had never been measured. | ||
| 164 | +* On the generated 3840x2160 4:2:2 stream the tail is non-zero on the first | ||
| 165 | + two frames and zero after (`pad_unwritten=4096/1024/1024` on frame 0, | ||
| 166 | + `2048/512/512` on frame 1) out of 61 440/15 360/15 360 scanned per frame — | ||
| 167 | + so a 4:2:2 frame does leave real unwritten tail behind at scale. | ||
| 168 | + | ||
| 169 | +### 2.4 Read census — measurement, and its non-vacuity | ||
| 170 | + | ||
| 171 | +The region census counts **unwritten** samples. It says nothing about reads, | ||
| 172 | +which is the whole question. Two independent read instruments: | ||
| 173 | + | ||
| 174 | +**(a) valgrind memcheck, differential.** Every fixture decoded twice under | ||
| 175 | +memcheck — once on `uninit` (the plane buffer is uninitialised, so any read of | ||
| 176 | +it is a memcheck error) and once on `zeroed`. **128 fixtures × 2 arms = 256 | ||
| 177 | +runs executed, zero uninitialised-value errors, identical error-signature sets | ||
| 178 | +on all 128.** 126 of the fixtures decode; two refuse. The sweep was run in two | ||
| 179 | +pieces — 127 fixtures on the pre-rebase tree, then the fixture that arrived | ||
| 180 | +with `d16af6c3` (`422_header_edge16_walk.obu`, 128 bytes) run separately under | ||
| 181 | +both arms on `f01e9738`: | ||
| 182 | + | ||
| 183 | +``` | ||
| 184 | +422_header_edge16_walk.obu uninit 0 zeroed 0 CLEAN (identical) | ||
| 185 | +raw, uninit arm: ERROR SUMMARY: 0 errors from 0 contexts | ||
| 186 | +raw, zeroed arm: ERROR SUMMARY: 0 errors from 0 contexts | ||
| 187 | +``` | ||
| 188 | + | ||
| 189 | +Those two runs are not vacuous, and that needed checking rather than assuming: | ||
| 190 | +the fixture refuses, so "0 errors" could have meant "the decoder allocated | ||
| 191 | +nothing". It did not. `EC_AV1_SUBSIZE_GUARD_TRACE=1` on it reports six | ||
| 192 | +`note_subsize_guard` sites reached, with the refusal FIRING at | ||
| 193 | +`decode.rs:37522` (`bsize=16x16 part=2 codable=false`) — that site is inside | ||
| 194 | +the tile walk, which is downstream of the three `fresh_plane` calls at | ||
| 195 | +`decode.rs:36007`/`36028`/`36040`. So the plane was allocated, partially | ||
| 196 | +written, and abandoned mid-walk, and memcheck saw an `uninit` buffer with a | ||
| 197 | +real partial write in it and still found nothing. | ||
| 198 | +> | ||
| 199 | +> One consequence for §2.3: this fixture prints **no** `SENTINEL_CENSUS` line, | ||
| 200 | +> because the refusal short-circuits through `?` before the census at the tail | ||
| 201 | +> of `decode_key_frame_tile_with_cdfs`. Its contribution is therefore 0 scanned | ||
| 202 | +> and 0 holes, which is why the §2.3 totals are identical for 127 and for 128 | ||
| 203 | +> files — and also why the census's `scanned` pairing cannot be dropped: a | ||
| 204 | +> fixture that contributes nothing looks exactly like one never looked at. | ||
| 205 | +> | ||
| 206 | + | ||
| 207 | +> **Non-vacuity, by mutation.** A temporary env-gated read of the plane's last | ||
| 208 | +> slot (`v[n-1]`, added to `fresh_plane`, reverted before commit) makes the same | ||
| 209 | +> binary on the same fixture report **12 errors from 4 contexts**: | ||
| 210 | +> `Conditional jump or move depends on uninitialised value(s)` ×3, | ||
| 211 | +> `Use of uninitialised value of size 8`. The instrument sees plane-sourced | ||
| 212 | +> uninitialised reads when they exist. | ||
| 213 | +> | ||
| 214 | +> That run also shows the ambient-content hazard concretely: the luma plane | ||
| 215 | +> (`n=30720`) errored and the two chroma planes (`n=7680`) happened to be handed | ||
| 216 | +> already-zero memory and did not. A same-machine run is not proof; a | ||
| 217 | +> *different* poison is. | ||
| 218 | + | ||
| 219 | +**(b) Differential poisoning.** Decode each fixture under two DIFFERENT | ||
| 220 | +impossible values for the plane buffer and compare the output hash. A read | ||
| 221 | +whose value reaches the picture changes the hash when the poison changes. | ||
| 222 | + | ||
| 223 | +| corpus | arms | result | | ||
| 224 | +|---|---|---| | ||
| 225 | +| 126 committed fixtures | `0xDEAD` / `0xBEEF` / `alloc_zeroed` | **126/126 byte-identical** | | ||
| 226 | +| `440_request_is_422` | — | REFUSED (§2.3) | | ||
| 227 | +| 4K 4:2:0, 4K 4:2:2, 1080p 4:2:0 | `0xDEAD`, `0xBEEF`, `0x0080`, `0x0001`, `0x0FFF`, `0x1000`, `0x2000`, `zeroed` | **8/8 identical per stream** | | ||
| 228 | + | ||
| 229 | +The last row needs a note on method. `plane_poison()` *refuses* a poison at or | ||
| 230 | +below `MAX_LEGAL_SAMPLE` (4095), because a legal poison makes the region census | ||
| 231 | +vacuous. To run the experiment anyway I temporarily removed that guard: the | ||
| 232 | +**legal-range** poisons (`0x0001`, `0x0080`, `0x0FFF`, `0x1000`, `0x2000`) then | ||
| 233 | +produce the same hash as the impossible ones. That matters because an | ||
| 234 | +out-of-range poison can be hidden by a clamp — every legal sample is | ||
| 235 | +`(1 << bit_depth) - 1` at most — while a legal-range poison is not. **No read | ||
| 236 | +survives clamping, masking or branch selection.** The guard is restored. | ||
| 237 | + | ||
| 238 | +### 2.5 Verdict of the census | ||
| 239 | + | ||
| 240 | +* **Region 1 (padded tail):** exists (4.68 M samples), is never written, and is | ||
| 241 | + **never read** — memcheck over 254 runs and 8 poisons agree. | ||
| 242 | +* **Region 2 (true extent):** **0 holes** across 1.47 G samples on every current | ||
| 243 | + fixture; the historical 224-sample case is behind a refusal. | ||
| 244 | +* **A third category, which neither instrument can see: `pix_write`.** Its | ||
| 245 | + `prev` argument is the destination sample's own value, read at four call | ||
| 246 | + sites on **every** reconstruction store. When a block is the first to write | ||
| 247 | + a sample, that read returns the buffer's initial content. It is still a read | ||
| 248 | + of a `u16` that (on the `uninit` arm) was never written. | ||
| 249 | + * Neither instrument reports it, and that is not a gap in them: `prev` is | ||
| 250 | + only consumed inside `if *PIXPROBE_ON`, so the value never reaches a | ||
| 251 | + branch, an address computation or a syscall — memcheck has nothing to | ||
| 252 | + complain about, and no hash can move. Verified directly: a **debug** build | ||
| 253 | + (no optimisation to dead-code-eliminate the load) under memcheck on the | ||
| 254 | + `uninit` arm still reports `0 errors from 0 contexts`. | ||
| 255 | + * So the honest reading is: the decoder provably does not *depend* on the | ||
| 256 | + buffer's initial content, and `pix_write` is the one place it reads it | ||
| 257 | + anyway. The shipped `Zeroed` closure deletes that read along with the rest, | ||
| 258 | + which is a second, independent reason to take it. | ||
| 259 | +* **A constraint on the census arms that is not obvious from their names.** | ||
| 260 | + `fresh_plane` returns `vec![plane_poison(); n]` BEFORE it matches on | ||
| 261 | + `plane_alloc()`, so `PadZero` and `ExtZero` never run while | ||
| 262 | + `EC_AV1_PLANE_SENTINEL` is set — and that flag is exactly what both census | ||
| 263 | + functions require (each returns early when it is off). Those two arms are | ||
| 264 | + therefore meaningful only under **memcheck with the sentinel OFF**, where | ||
| 265 | + the zeroed/uninitialised split between the regions is what memcheck keys on; | ||
| 266 | + under the sentinel they are inert. The order is deliberate and stays: | ||
| 267 | + moving the sentinel check below the match would let the region census scan a | ||
| 268 | + buffer the sentinel never poisoned, which it cannot recover from. | ||
| 269 | +* **Neither is reachable today.** That is a statement about today's corpus, not | ||
| 270 | + a proof: a hostile file chooses its own subsize values, and the refusal that | ||
| 271 | + closes region 2 lives in the tile walk, not at the allocation. Hence the | ||
| 272 | + decision below rather than "the premise holds". | ||
| 273 | + | ||
| 274 | +--- | ||
| 275 | + | ||
| 276 | +## 3. The decision, and the evidence behind it | ||
| 277 | + | ||
| 278 | +The charter's rule: *if (b) is within noise of (a) and close to the baseline, | ||
| 279 | +implement (b) and prove determinism; if (b) is expensive and (a) is too, leave | ||
| 280 | +the allocation alone.* | ||
| 281 | + | ||
| 282 | +* (b) **is** within noise of (a) — 0.03 % apart at all three sizes. | ||
| 283 | +* (b) is **not** within noise of the baseline at 4K: +0.84 % with a 6–10 ms | ||
| 284 | + run-to-run spread, i.e. ~6σ. So the charter's first branch is not literally | ||
| 285 | + satisfied. | ||
| 286 | + | ||
| 287 | +I took (b) anyway, and the reason is the shape of the risk, not the size of the | ||
| 288 | +number: | ||
| 289 | + | ||
| 290 | +1. **The alternative is not "keep the unsafe", it is "keep asserting a premise | ||
| 291 | + that has already been withdrawn once."** That premise is what | ||
| 292 | + `lanes/unwritten-dep.report.md` §12 filed, and it produced a caller-visible | ||
| 293 | + defect. A 0.84 % regression is visible in a benchmark; a withdrawn SAFETY | ||
| 294 | + premise is invisible until it ships. | ||
| 295 | +2. **The sign of the cost is not stable across resolutions** (§1). A decision to | ||
| 296 | + pay it should be made knowing it is ~0.85 % at 4K and a ~1.6 % *win* at 1080p, | ||
| 297 | + not "always 0.8 %". | ||
| 298 | +3. **The decision is reversible in one line.** `EC_AV1_PLANE_ALLOC=uninit` | ||
| 299 | + restores the status quo exactly, which is only true because the closure is an | ||
| 300 | + env arm and not a build flag. | ||
| 301 | + | ||
| 302 | +**Determinism proof** — new gate | ||
| 303 | +`stream::tests::the_frame_does_not_depend_on_the_plane_buffers_initial_content` | ||
| 304 | +(`stream.rs:48496`), which is exactly the charter's test: | ||
| 305 | + | ||
| 306 | +* four child processes, same ten fixtures each: `EC_AV1_PLANE_SENTINEL=0xDEAD`, | ||
| 307 | + `EC_AV1_PLANE_SENTINEL=0xBEEF`, sentinel-off + `EC_AV1_PLANE_ALLOC=uninit`, | ||
| 308 | + sentinel-off + `EC_AV1_PLANE_ALLOC=zeroed`; | ||
| 309 | +* one FNV-1a hash per fixture over every shown frame's Y/U/V samples; all four | ||
| 310 | + arms must agree, per fixture; | ||
| 311 | +* **non-vacuity first, synthetic**: two pictures differing in ONE sample must | ||
| 312 | + hash differently, or every equality below would be vacuous; | ||
| 313 | +* every arm must report `frames > 0`, so a child that decoded nothing cannot | ||
| 314 | + agree with another child that decoded nothing. | ||
| 315 | + | ||
| 316 | +Fixture list deliberately small: a first revision used the 1920x792 film | ||
| 317 | +fixtures and took **252 s** in a debug build, which is not a gate anyone keeps. | ||
| 318 | +The committed ten (4:2:2 12-bit key / inter / sb128 intrabc / 17-frame odd | ||
| 319 | +size, 4:4:4 lossless-sb64 / intrabc-rect4 / 128-root-mu, a padded odd size, an | ||
| 320 | +off-tile chroma walk, superres+CDEF+LR) run the gate in **4.6 s**. | ||
| 321 | + | ||
| 322 | +--- | ||
| 323 | + | ||
| 324 | +## 4. What changed | ||
| 325 | + | ||
| 326 | +* `decode.rs` — `PlaneAlloc` (five arms), `plane_alloc()`, `zero_pad()`, | ||
| 327 | + `zero_extent()`, `plane_poison()` (a settable poison so two-value | ||
| 328 | + differential poisoning is possible; a poison ≤ 4095 is still refused), | ||
| 329 | + `MAX_LEGAL_SAMPLE`, the pad-tail census (`PAD_UNWRITTEN_SAMPLES`, | ||
| 330 | + `PAD_CENSUS_SCANNED` + accessors), `census_unwritten` extended to scan both | ||
| 331 | + regions, `census_unwritten_final` switched to `plane_poison()`, | ||
| 332 | + `fresh_plane` taking the plane geometry, and **`PlaneAlloc::Zeroed` as the | ||
| 333 | + default**, which puts the `unsafe` behind an env arm. | ||
| 334 | +* `stream.rs` — the determinism gate, its child, and the synthetic control. | ||
| 335 | +* `examples/alloc_timing.rs` — the decode-wall-time / page-fault harness. | ||
| 336 | +* Hunks are confined to the allocation path: `decode.rs` `fresh_plane` and the | ||
| 337 | + six `PlaneBuf { … }` construction sites (3 planes × the key and inter frame | ||
| 338 | + functions), plus the census block next to them. The peer lane | ||
| 339 | + `lane/av1subsizesweep` touches `decode.rs` at ~37063 and ~57061 (a | ||
| 340 | + superblock arm and its tests); there is no overlap. | ||
| 341 | + | ||
| 342 | +### SAFETY comment | ||
| 343 | + | ||
| 344 | +Rewritten to state **what can be read before it is written** — the three named | ||
| 345 | +regions with their measured counts, the memcheck result, the refusal that | ||
| 346 | +covers region 2, and the fact that the shipped arm never reaches the `unsafe` | ||
| 347 | +at all. The withdrawn premise ("written sample-for-sample before anything reads | ||
| 348 | +it") is gone; nothing in the comment asserts a premise a reviewer cannot | ||
| 349 | +re-run. | ||
| 350 | + | ||
| 351 | +--- | ||
| 352 | + | ||
| 353 | +## 5. Gates | ||
| 354 | + | ||
| 355 | +``` | ||
| 356 | +cargo check -p ec-av1 --tests ok | ||
| 357 | +cargo test -p ec-av1 --lib -- 422 14 passed, 0 failed | ||
| 358 | +cargo test -p ec-av1 --lib -- 444 50 passed, 0 failed | ||
| 359 | +cargo test -p ec-av1 --lib -- sub8 13 passed, 0 failed | ||
| 360 | +cargo test -p ec-av1 --lib -- lossless 34 passed, 0 failed | ||
| 361 | +``` | ||
| 362 | +Re-run on the rebased tree (`f01e9738`), where main's own `1f4fcc84` guard for | ||
| 363 | +the census child test is present: | ||
| 364 | +``` | ||
| 365 | +cargo test -p ec-av1 --lib -- the_frame 13 passed, 0 failed | ||
| 366 | + (includes the_frame_does_not_depend_on_the_plane_buffers_initial_content) | ||
| 367 | +cargo test -p ec-av1 --lib -- unwritten 2 passed, 0 failed | ||
| 368 | +``` | ||
| 369 | + | ||
| 370 | +**One gate was red on the lane's original base and is not this lane's.** On | ||
| 371 | +`2d8fa8a4`, `cargo test -p ec-av1 --lib -- unwritten` reported | ||
| 372 | +`1 passed, 1 FAILED`: `stream::tests::uwdep_child_unwritten_census` opens with | ||
| 373 | +an unconditional `assert!(EC_AV1_PLANE_SENTINEL is set)` while sitting in the | ||
| 374 | +crate's default test list, so any standalone run of that filter fails. Main | ||
| 375 | +commit `1f4fcc84` ("the census child test skips in a normal suite run instead | ||
| 376 | +of reddening it") adds the entry guard and it is **not** an ancestor of this | ||
| 377 | +lane's original base. Nothing in this lane touches that test. | ||
| 378 | + | ||
| 379 | +--- | ||
| 380 | + | ||
| 381 | +## 7. Rebase onto `f01e9738` | ||
| 382 | + | ||
| 383 | +Main moved while this lane was measuring. The branch is rebased onto `f01e9738` | ||
| 384 | +and every headline number was re-taken there; the only conflict was in the | ||
| 385 | +`census_unwritten` doc comment, resolved by keeping main's coverage paragraph | ||
| 386 | +("this census runs at TWO of the four places `apply_deblock` is entered from") | ||
| 387 | +*and* the two-region text, since both intents hold. Main's delta also adds | ||
| 388 | +`chroma_plane_block_codable` to the 16-level edge arm — the guard that refuses | ||
| 389 | +the 4:2:2 subsize by name. | ||
| 390 | + | ||
| 391 | +What changed on the rebased tree, re-measured: | ||
| 392 | +* the 3840x2160 4:2:0 row (§1) — `zeroed` +0.84 %, `fill` +0.92 %; same hashes, | ||
| 393 | + same `minflt`, same conclusion; | ||
| 394 | +* the poison sweep — 126 identical, **2** refused: `440_request_is_422` and, | ||
| 395 | + newly, `422_header_edge16_walk`, which main's new guard refuses; | ||
| 396 | +* the region census — **byte-identical totals**: 1,466,581,280 extent samples, | ||
| 397 | + 0 holes; 22,787,296 pad samples, 4,676,128 holes; 38 fixtures. | ||
| 398 | + | ||
| 399 | +--- | ||
| 400 | + | ||
| 401 | +## 8. Left undone, deliberately | ||
| 402 | + | ||
| 403 | +* **A pooled plane buffer** would make the closure ~free: take the three plane | ||
| 404 | + buffers from a thread-local pool, zero each ONCE at creation, return them on | ||
| 405 | + drop. Every sample is then initialised by construction and the per-frame | ||
| 406 | + memset disappears. It is not done here because it changes ownership | ||
| 407 | + (`PlaneBuf` holds `Cow<'a, [u16]>` and is handed to the wavefront workers), | ||
| 408 | + which is a different lane's worth of risk than this charter took on. | ||
| 409 | +* **The 1080p sign flip is unexplained.** §1. | ||
| 410 | +* **Reader attribution for a region-2 read** is only as deep as "a reader that | ||
| 411 | + does not clamp". With no current fixture reaching region 2 there is nothing to | ||
| 412 | + attribute; `EC_AV1_PLANE_ALLOC=padzero` / `extzero` are in the tree for | ||
| 413 | + whoever gets one — under memcheck with the sentinel OFF, per the ordering | ||
| 414 | + constraint in §2.5. | ||
| \ No newline at end of file | \ No newline at end of file | ||