From 1fc2eb056032d9fbea203ad9a05691941e9474cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Sun, 30 Aug 2026 07:14:31 +0300 Subject: [PATCH] fix(av1): oracle lives in ~/.cache, not reaped /tmp -- 20 gates were silently vacuous A tmpfs reclaim wiped /tmp/libaom-src between sessions. aomenc_path()'s only default pointed there, so every one of the 20 aomenc gates hit the SKIP branch and the suite stayed green while proving nothing. - scripts/build-aom-oracle.sh provisions source + aomenc/aomdec under ~/.cache/aom-oracle (pinned v3.13.3, AOM_TARGET_CPU=generic since this box has no nasm; measured same 15.3s/gate as the old SIMD build). - aomenc_path() searches the durable location first, /tmp last (legacy). - EC_AV1_REQUIRE_AOMENC=1 turns a missing oracle into a hard failure so a batch run cannot report green off 20 skips. EVIDENCE: free-partition gate with EC_AV1_REQUIRE_AOMENC=1 -- 5 pixel-exact matches, rect_partition_hits=7 partab_hits=2, 15.34s. --- crates/ec-av1/src/stream.rs | 33 +++++++++++++++++++++++++++++---- scripts/build-aom-oracle.sh | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 4 deletions(-) create mode 100755 scripts/build-aom-oracle.sh diff --git a/crates/ec-av1/src/stream.rs b/crates/ec-av1/src/stream.rs index ba2f3685..691c0267 100644 --- a/crates/ec-av1/src/stream.rs +++ b/crates/ec-av1/src/stream.rs @@ -1111,13 +1111,38 @@ mod tests { /// default dev-build path; the test skips (not fails) when neither this /// nor `ffmpeg` is present. fn aomenc_path() -> std::path::PathBuf { - std::env::var_os("EC_AV1_AOMENC") - .map(std::path::PathBuf::from) - .unwrap_or_else(|| "/tmp/libaom-src/build/encoder/aomenc".into()) + if let Some(p) = std::env::var_os("EC_AV1_AOMENC") { + return std::path::PathBuf::from(p); + } + // The oracle used to live only under `/tmp`, which this box's tmpfs + // guard reclaims -- when it did, all 20 aomenc gates below went + // silently vacuous (SKIP, suite still green). The durable location + // is provisioned by `scripts/build-aom-oracle.sh`; the `/tmp` path + // stays last as a legacy fallback. + let mut candidates = Vec::new(); + if let Some(home) = std::env::var_os("HOME") { + candidates.push(std::path::PathBuf::from(&home).join(".cache/aom-oracle/build/aomenc")); + } + candidates.push("/tmp/libaom-src/build/encoder/aomenc".into()); + candidates + .iter() + .find(|p| p.is_file()) + .cloned() + .unwrap_or_else(|| candidates.remove(0)) } + /// Whether the aomenc oracle is present. Absence normally SKIPs (a + /// checkout without the oracle should still run the rest of the suite), + /// but `EC_AV1_REQUIRE_AOMENC=1` turns it into a hard failure so a batch + /// run cannot report green off 20 skipped gates. fn have_aomenc() -> bool { - aomenc_path().is_file() + let present = aomenc_path().is_file(); + assert!( + present || std::env::var_os("EC_AV1_REQUIRE_AOMENC").is_none(), + "EC_AV1_REQUIRE_AOMENC is set but no aomenc at {} -- run scripts/build-aom-oracle.sh", + aomenc_path().display() + ); + present } /// A real `aomenc` filter-intra fixture: every other intra mode disabled diff --git a/scripts/build-aom-oracle.sh b/scripts/build-aom-oracle.sh new file mode 100755 index 00000000..098807e4 --- /dev/null +++ b/scripts/build-aom-oracle.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# Provision the libaom oracle the ec-av1 gates and every decode-verification +# claim depend on: the C source (read as ground truth) plus aomenc/aomdec. +# +# It lives under ~/.cache, NOT /tmp: on 2026-08-30 a tmpfs reclaim wiped +# /tmp/libaom-src and all 20 aomenc gates in crates/ec-av1/src/stream.rs +# started SKIPping, leaving a green-but-vacuous suite. Re-run this whenever +# `cargo test -p ec-av1` prints "SKIP ...: no aomenc at ...". +# +# nasm/yasm are absent on this box, so the build uses AOM_TARGET_CPU=generic +# (C only). Decode is normative, so aomdec stays bit-exact; encode is slower. +# Install nasm and drop that flag for a faster oracle. +set -euo pipefail + +VERSION="${AOM_VERSION:-v3.13.3}" +ROOT="${AOM_ORACLE_ROOT:-$HOME/.cache/aom-oracle}" +SRC="$ROOT/src" +BUILD="$ROOT/build" + +if [ ! -d "$SRC/.git" ]; then + git clone --depth 1 --branch "$VERSION" https://aomedia.googlesource.com/aom "$SRC" +fi + +cmake -S "$SRC" -B "$BUILD" -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_TESTS=0 -DENABLE_DOCS=0 -DENABLE_EXAMPLES=1 \ + -DCONFIG_INSPECTION=1 \ + -DAOM_TARGET_CPU="${AOM_TARGET_CPU:-generic}" +ninja -C "$BUILD" aomenc aomdec + +echo "oracle ready:" +echo " source $SRC" +echo " aomenc $BUILD/aomenc" +echo " aomdec $BUILD/aomdec"