lanes: opus-perf-r1.report.md — PVQ U-table lands (5.1 decode 0.70 -> 0.82 of ruopus-FFT, stereo 0.66 -> 0.88, encode 0.59 -> 0.65 of opus-rs), profiles show the FFT is ~10% and the PVQ walk dominates, two search experiments measured and reverted, server-3 cross-check queued
Browse files at this commit67663b9c047effbe2e9b9b5ef41227214e092e04Parent: e06f8b91 changed file +104 -0
- lanes/opus-perf-r1.report.md +104 -0
lanes/opus-perf-r1.report.mdadded+104 -0
| @@ -0,0 +1,104 @@ | ||
| 1 | +# lane-opusperf — ec-opus speed A/B vs the FFT-built comparators (r1) | |
| 2 | + | |
| 3 | +Charter: close the ~1.5x ec-opus speed gap vs ruopus 0.1.2 [std, spectrograms] | |
| 4 | +(decode) and opus-rs 0.1.26 (encode), the exact builds the old edith seats ran. | |
| 5 | +Branch lane-opusperf off d27a904d. Worktree-only; no merges, no pushes. | |
| 6 | + | |
| 7 | +## Method | |
| 8 | + | |
| 9 | +- A/B harness: `~/Documents/Code/Rust/opus-perf-ab` (scratch crate, outside the | |
| 10 | + family workspace; ec-opus by path into THIS worktree). Also rsynced to | |
| 11 | + server-3 (user@host-b, `~/opusperf/`) with the media. | |
| 12 | +- Media: a real 5.1 film (`~/Videos/Films/reelc.mkv`, | |
| 13 | + read-only). `full51.opus` = the full 5.1 track remuxed by ffmpeg (clean); | |
| 14 | + `film2.opus` = libopus 256k stereo transcode of the 600–1320 s window; | |
| 15 | + `film2_seg.f32` / `film51_seg.f32` = 120 s of f32 PCM from the 600–720 s | |
| 16 | + window. Both sides of every pair get byte-identical inputs. | |
| 17 | +- Protocol per row: one warm-up pass each side, then 7 alternating rounds | |
| 18 | + (A/B and B/A by round), min per side, `/proc/loadavg` captured per round. | |
| 19 | + Cross-check before the decode rows: both 5.1 decoders over 25 packets, | |
| 20 | + worst-channel correlation > 0.999, final_range equality asserted. | |
| 21 | +- Profiles: perf record/annotate on a `prof` driver looping one workload. | |
| 22 | + | |
| 23 | +## Baseline (d27a904d, local, loadavg 3.0–3.4) | |
| 24 | + | |
| 25 | +| row | ec-opus | comparator | ratio | | |
| 26 | +|---|---|---|---| | |
| 27 | +| decode 5.1 120 s film | 170–174x | 246–248x ruopus | 0.69–0.70 | | |
| 28 | +| decode stereo 120 s film | 346x | 524x ruopus | 0.66 | | |
| 29 | +| encode 128k CBR stereo | 261x | 438x opus-rs | 0.59 | | |
| 30 | +| encode 256k CBR stereo | 187x | 319x opus-rs | 0.59 | | |
| 31 | + | |
| 32 | +(The campaign's local numbers, 246x vs 407x / 1.41–1.57x, were taken on a | |
| 33 | +quieter box; sibling lanes were running during this round. All comparisons | |
| 34 | +below are same-session pairs, so ratios stay comparable.) | |
| 35 | + | |
| 36 | +## Profile (the assignment's FFT hypothesis is wrong for both paths) | |
| 37 | + | |
| 38 | +- decode stereo: `quant_band` 65% — inside it `decode_pulses` 43% | |
| 39 | + (pvq_urow row-stepping 19% + uprev 11%); FFT (Fft15::inverse + | |
| 40 | + inverse_split) ~10%. | |
| 41 | +- encode 256k: `quant_band` ~60–64% — `alg_quant` ~51% (search + init + | |
| 42 | + encode_pulses 14%); FFT+MDCT ~9%. `floorf` 3.6%, stereo_itheta's f64 | |
| 43 | + atan2 ~2.5%. | |
| 44 | + | |
| 45 | +## Landed | |
| 46 | + | |
| 47 | +### 88f22a66 — PVQ U-table (decode + encode) | |
| 48 | + | |
| 49 | +`decode_pulses`/`encode_pulses` now read the reference non-custom build's | |
| 50 | +1272-entry flat `U` table (const-computed from the same recurrence in | |
| 51 | +wrapping arithmetic; layout `U(m,c)` at `PVQ_U_ROW[m]+c`, symmetric in | |
| 52 | +min(n,k)) instead of stepping `U` rows at runtime: O(N) lookups vs O(N·K) | |
| 53 | +arithmetic. Decoder/encoder `urow` scratch fields deleted; a lib test | |
| 54 | +cross-checks every stored entry against a fresh runtime row-stepping build. | |
| 55 | + | |
| 56 | +Fidelity: full `cargo test -p ec-opus --release` green per commit (35 lib + | |
| 57 | +28 conformance: RFC 6716 vectors range-state-exact, ffmpeg/libopus | |
| 58 | +correlation gates, oracle rate table, roundtrips at every rate, | |
| 59 | +garbage-payload fuzz, speed floors). Zero warnings (`#![forbid(unsafe_code)]` | |
| 60 | +holds). | |
| 61 | + | |
| 62 | +Committed state, local, loadavg 0.3–7 (two consistent batteries): | |
| 63 | + | |
| 64 | +| row | ec-opus | comparator | ratio | baseline | | |
| 65 | +|---|---|---|---|---| | |
| 66 | +| decode 5.1 | 207x | 251–254x ruopus | 0.82 | 0.70 | | |
| 67 | +| decode stereo | 461–465x | 529–533x ruopus | 0.86–0.88 | 0.66 | | |
| 68 | +| encode 128k CBR | 275–276x | 429–431x opus-rs | 0.64 | 0.59 | | |
| 69 | +| encode 256k CBR | 204–205x | 316–317x opus-rs | 0.65 | 0.59 | | |
| 70 | +| encode 510k CBR | 185–187x | 201–202x opus-rs | 0.92 | n/a | | |
| 71 | +| encode 256k VBR | 204–206x | 315–317x opus-rs | 0.65 | n/a | | |
| 72 | +| encode 256k | 204–206x | 408–411x ruopus | 0.50 | n/a | | |
| 73 | +| encode 5.1 384k (absolute; no comparator has a multistream encoder) | 87x | — | — | n/a | | |
| 74 | + | |
| 75 | +## Measured and reverted (both on top of 88f22a66, not committed) | |
| 76 | + | |
| 77 | +- FOUR independent champion groups in the vector sweep (killing the serial | |
| 78 | + compare chain): no change — 0.65 at 256k either way. The chain was not the | |
| 79 | + bottleneck. | |
| 80 | +- Padded 8-lane sweep for ALL band sizes (pad `yy` = 1e17 sentinel): REGRESSED | |
| 81 | + encode to 153x / 0.48 at 256k. Instrumented counts | |
| 82 | + (2.24 M alg_quant calls, 398 M scalar lane-visits vs 12 M vector | |
| 83 | + chunk-visits) made small bands look dominant, but each small-band scalar | |
| 84 | + visit is cheap and an 8-lane sweep of a 4-sample band wastes lanes. Reverted | |
| 85 | + (`git checkout`); the instrumentation came out with it. | |
| 86 | + | |
| 87 | +## What remains | |
| 88 | + | |
| 89 | +1. server-3 clean-machine A/B (media + harness already in `~/opusperf` there) for | |
| 90 | + an uncontended final table; local numbers above carry sibling load. | |
| 91 | +2. decode 5.1: 0.82 vs the 0.9 target. The remaining decode cost is spread | |
| 92 | + (PVQ walk now table-driven); candidates: `bits2pulses` (2.7% linear scan), | |
| 93 | + `dec_uint` path, denorm/deemphasis loops. | |
| 94 | +3. encode 256k: 0.65 vs the 0.8 target. The comparator's search is rsqrt-form | |
| 95 | + AVX2 (libopus 1.6 port); `#![forbid(unsafe_code)]` rules out intrinsics and | |
| 96 | + `wide` has no rsqrt, so the lever is either a safe rsqrt approximation | |
| 97 | + (bit-trick via `to_bits`, needs a wide/i32 bridge) or reducing searches | |
| 98 | + (allocation shape). `stereo_itheta`'s f64 `atan2` (≈2.5%) → the crate's own | |
| 99 | + `fast_atan2f` is a safe small win. | |
| 100 | +4. FFT/MDCT lever (~9–10% of each path): realfft behind a default feature or | |
| 101 | + further kernel shaping — worth it only after 2–3. | |
| 102 | + | |
| 103 | +Housekeeping: `opus-perf-ab` is a scratch crate outside the family tree; | |
| 104 | +`fixtures` symlink in the worktree root is gitignored as usual. |