Skip to content

perf(bench): record the audio-tick pair's ratio exemption (#3138) - #3152

Closed
zackees wants to merge 2 commits into
masterfrom
fix/3138-bound-exemption
Closed

zackees wants to merge 2 commits into
masterfrom
fix/3138-bound-exemption

Conversation

@zackees

@zackees zackees commented Oct 31, 2026

Copy link
Copy Markdown
Member

Fixes #3138.

The maintainer decided on #3138 (option 1): audio_mix/buffering_add_one_tick
stays above the 1.10 ratio and is exempted by name in the recorder, with
its absolute cost recorded — do not add the push_ts_front fast path. Since
#3141 removed the real inefficiencies, what is left (~46 ns vs the C's ~41 ns,
once per audio tick) is the Rust/C boundary itself.

Change

  • record.py gains RATIO_EXEMPTIONS, one entry per exempt pair: the
    absolute cost, the reason, and the decision that made it. summarize keeps
    that reason on the row (exemption) and its status reads
    exempt from the ratio bound, so a report shows the decision instead of a
    silent pass.
  • over_bound skips an exempt pair, so --max-ratio still fails every other
    breach.
  • docs/rust-port/release-criteria.md records the exemption beside the bound.

RED

24dce5672 adds the tests only:

uv run python -m unittest test_benchmark_record.py
Ran 16 tests ... FAILED (failures=1, errors=1)
  ERROR  record.RATIO_EXEMPTIONS does not exist
  FAIL   over_bound still reports the exempt pair

The over-bound case now uses format/i420_to_uyvx/1080p, so the gate keeps a
witness that is not exempt.

GREEN

17c6be328 adds the exemption. Ran 16 tests ... OK.

End-to-end, on this host, warm caches (--cpu 7, three complete runs):

uv run rust/tools/benchmarks/record.py --category audio_mix --repeats 3 \
    --cpu 7 --max-ratio 1.10 --output /tmp/audio_mix_3138.json
Recorded 12 complete comparisons
exit 0

The recorded row, in a loaded-box run:

{"benchmark": "audio_mix/buffering_add_one_tick", "rust_over_c": 1.157,
 "status": "exempt from the ratio bound",
 "exemption": "~46 ns vs the C's ~41 ns per call, once per audio tick: ..."}

Every other audio_mix pair in that run is at or below the bound (0.26-1.06).

Checks: uv run ci/local_gate.py --lane lint ok (55.7 s), test_benchmark_record.py
16 tests OK.

Noticed, not fixed here

summarize renders the bound as {BOUND:.0%}, and BOUND is a ratio, so a
passing row's status reads within 110% bound (and a breach over 110% bound).
That predates this PR and is only a label; I left it out to keep this unit to
the exemption, and can file it as an infra: follow-up if you want it fixed.

…gate (#3138)

The maintainer decided (#3138) that `audio_mix/buffering_add_one_tick`
stays above the 1.10 ratio: after #3141 removed the real inefficiencies the
residual is the Rust/C boundary itself (~46 ns vs ~41 ns per call, once per
audio tick), and the recorder should record that as an exemption rather than
a breach. So the gate needs a named exemption, its reason in the report, and
the over-bound case must use a pair that is not exempt.

Fails on this commit: `record.RATIO_EXEMPTIONS` does not exist, and
`over_bound` still reports the exempt pair.
The maintainer decided (#3138) that `audio_mix/buffering_add_one_tick` stays
above the 1.10 ratio and is exempt instead: what is left after #3141 is the
Rust/C boundary itself (~46 ns vs ~41 ns per call, once per audio tick).

- `RATIO_EXEMPTIONS` names the pair with that absolute cost and reason;
  `summarize` keeps the reason in the row as `exemption` and its status reads
  `exempt from the ratio bound`, so the report shows the decision.
- `over_bound` skips an exempt pair, so `--max-ratio 1.10` passes on a run
  that records it at 1.157 and still fails on any other breach.
- `docs/rust-port/release-criteria.md` records the exemption next to the bound.

End-to-end: `record.py --category audio_mix --repeats 3 --cpu 7
--max-ratio 1.10` exits 0 and records 1.157 with the exemption.
@zackees

zackees commented Oct 31, 2026

Copy link
Copy Markdown
Member Author

Superseded by #3153, which carries the same change (identical file set) with the recorded Decided: on #3138 and a green CI Gate ✅. Closing to avoid two queue entries for one unit.

@zackees zackees closed this Oct 31, 2026
@zackees
zackees deleted the fix/3138-bound-exemption branch October 31, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

perf: audio_mix/buffering_add_one_tick is 1.19-1.30x the C, above the 1.10x bound

1 participant