edith_codecs
Clone
https://git.tahinli.com/Tahinli/edith_codecs.git
0 watching·0 forks·Rust·370.3 MiB·9b67700·Tahinli·3 days ago·4021 commits
| 1 | # av1splitp0: test-only source reader for module directories (plan step P0) |
| 2 | |
| 3 | Base: `main` @ d271a92b (rebased; the ec-av1 tree is identical between e6274ff1 and d271a92b, and the rebased-in commits touch no crates/ec-av1 file). Plan: `lanes/av1split.plan.md`, sections 1a and Phase 0. |
| 4 | |
| 5 | ## Goal |
| 6 | |
| 7 | The source-scanning tests read files by path with `include_str!("decode.rs")` and friends. |
| 8 | Once `decode.rs`, `stream.rs`, `encode.rs`, `tile.rs`, `qm.rs`, `encoder.rs` and `cdf.rs` become |
| 9 | directories, those includes stop compiling. This step repoints them so a later split changes |
| 10 | no test, and it moves 0 lines of production code. |
| 11 | |
| 12 | ## What changed |
| 13 | |
| 14 | - `crates/ec-av1/src/test_source.rs` (new, `#![cfg(test)]`, declared `#[cfg(test)] mod test_source;` |
| 15 | in `lib.rs`). Two helpers, both returning `&'static str` (each module is read once per process |
| 16 | and cached): |
| 17 | - `module_source(name)`: `src/<name>.rs` if present, plus every `*.rs` under `src/<name>/` |
| 18 | recursively, in sorted path order. Read at test run time from `CARGO_MANIFEST_DIR/src`. |
| 19 | Panics if the module has neither form, so a typo cannot read as an empty module. |
| 20 | - `module_production_source(name)`: the same, minus test-only files (`tests.rs`, `*_tests.rs`). |
| 21 | Used where a gate scans a module's production body (see below). |
| 22 | - Every `include_str!` of one of the seven split modules is replaced by `module_source(..)`, in |
| 23 | `gate_coverage.rs`, `stack_budget.rs`, `refusal_inventory.rs`, `decode.rs`, `stream.rs`, |
| 24 | `encode.rs`. Non-split includes (`cdf_state.rs`, `lib.rs`, `stack_budget.rs`, ...) are unchanged. |
| 25 | - Sites that cut the production prefix at the inline `mod tests` marker now take that prefix from |
| 26 | `module_production_source`: three `decode_body` sites in `decode.rs`, and `head(..)` in the |
| 27 | encode chroma gate (`encode.rs`). Without this, after a split the test files would be counted as |
| 28 | production text and the census would change meaning. For an unsplit file the result is the same. |
| 29 | - `stack_budget.rs`: the `const FILES` table became `fn files()`, since the entries are now read at |
| 30 | run time. The seven split modules come from the helper, so a new `decode/foo.rs` is scanned |
| 31 | automatically. `test_source.rs` is listed, which `every_by_value_module_is_scanned` requires |
| 32 | because `lib.rs` declares it. The local `FILES` in the encoder pin test became a `let`. |
| 33 | - `refusal_inventory.rs`: `const GATE_SOURCES` became `fn gate_sources()`, same reason. |
| 34 | - Two bindings that became unused after the change were removed: `encoder_src` in `encode.rs` and |
| 35 | `src` in one `decode.rs` gate (clippy caught both). |
| 36 | |
| 37 | Production code: no change. Diff is 91 insertions, 83 deletions, plus the new file. |
| 38 | |
| 39 | ## Verify |
| 40 | |
| 41 | Commands run through `scripts/remote-run.sh av1splitp0 -- <cmd>` (every run landed on host c, or a |
| 42 | after host c was busy). Logs are in `~/.cache/av1splitp0-logs/`. |
| 43 | |
| 44 | | Check | Baseline (main, unmodified) | After | |
| 45 | |---|---|---| |
| 46 | | `cargo test -p ec-av1 --release --lib -- --list` (count) | 856 tests, 0 benchmarks | 856 tests, 0 benchmarks | |
| 47 | | `cargo test -p ec-av1 --release --lib -- gate_coverage stack_budget` | 28 passed, 0 failed | 28 passed, 0 failed | |
| 48 | | full `cargo test -p ec-av1 --release --lib` | not run on base | 807 passed, 0 failed, 49 ignored (see note) | |
| 49 | | `cargo clippy -p ec-av1 --all-targets` | lib test: 321 warnings, 1 deny-level error (below) | 321 warnings, same per-file counts | |
| 50 | | `cargo check --workspace --all-targets` (5 probes) | not run on base | Finished, exit 0 (probes compile) | |
| 51 | |
| 52 | Notes: |
| 53 | - The full suite's first run was killed by the memory guard (`SIGKILL` from |
| 54 | `memguard-runner.sh` at the default 3500M cap, after 339 tests passed). The rerun used |
| 55 | `EC_MEMGUARD_MAX=10G -- --test-threads=4` and passed 807 with 0 failed. The 49 ignored tests are |
| 56 | pre-existing `#[ignore]`s; this diff adds none, and it removes no test. |
| 57 | - Final-tree targeted run after the last two cosmetic edits (unused bindings, indentation): |
| 58 | `gate_coverage stack_budget refusal_inventory` plus the decode/encode pins by name: 55 passed, |
| 59 | 0 failed. |
| 60 | - Clippy: the baseline already fails `ec-av1 (lib test)` on a deny-level lint at |
| 61 | `gate_coverage.rs:2645` (`unpinned <= UNPINNED_CEILING`, absurd comparison). That is not from this |
| 62 | lane and was left alone. Per-file warning counts were compared before and after and are identical. |
| 63 | - `cargo check --workspace --all-targets` shows 14 warnings in lib and probe code. None is in the |
| 64 | test-only code this step touched; cfg(test) code is not compiled by that command. |
| 65 | |
| 66 | ## Split proof (scratch, reverted) |
| 67 | |
| 68 | In the worktree, uncommitted: `git mv crates/ec-av1/src/qm.rs crates/ec-av1/src/qm/mod.rs`, then |
| 69 | `scripts/remote-run.sh av1splitp0 -- cargo test -p ec-av1 --release --lib -- gate_coverage stack_budget` |
| 70 | gave 28 passed, 0 failed. The rename was then reverted with `git mv` back and the empty directory |
| 71 | removed. Nothing from it is committed. |
| 72 | |
| 73 | ## Left |
| 74 | |
| 75 | - Steps D1 onward (`decode.rs` to `decode/mod.rs` and beyond) are not started. |
| 76 | - The pre-existing clippy deny error in `gate_coverage.rs:2645` still blocks a clean |
| 77 | `cargo clippy --all-targets -- -D warnings` on ec-av1. |