Repository navigation
perf(bench): Record the SIMD candidates and repair the benchmark recorder (#3003) - #3029
Conversation
…er (#3003) record.py requires the bench group prefixes to equal its 14 categories, but the port benches added since #1997 bring about 38 more, so a full run stops with "incomplete benchmark inventory". Its source fingerprint also misses most port crates, among them obs-media-io, obs-audio-controls and obs-core. The test asks for: the categories as a required set with other groups allowed; format, volmeter and audiomix among them (#3009); every Rust crate in the fingerprint; and a filter that runs only some categories. It fails on the current record.py. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… inventory (#3003) record.py: - CATEGORIES is the required set: a full run needs all of them and records the bench groups of the ports too. format, volmeter and audio_mix join it as the SIMD candidates of #3009. - --category (repeatable) runs and requires only the named categories, for the before and after numbers of one kernel. - The source fingerprint covers all of rust/ (build directories excluded), so a change in any port crate during a run is found. Benches (rust/obs-c-oracle/benches/port_comparison/): - format.rs: the six format-conversion entry points on a 1080p frame, each against the shipped C (SSE2 on x86) and against the same C on the plain-C SSE stand-ins. Both sides must write the same bytes. - volmeter.rs: sample peak and true peak of one tick (1024 frames). oracle/audio_controls.c exports the two static C kernels as oracle_get_sample_peak/oracle_get_true_peak; obs-audio-controls makes its peak module public (doc-hidden) for the benches. The results are bit-identical. - audio_output_tick.rs: one audio output tick with 6 mixes of planar stereo, so the output clamp (to [-1, 1], NaN to 0) runs on clipped samples and NaNs. The clamped samples are bit-identical. The mix add itself is already benched as audio_mix/mix_whole_tick and mix_from_frame_300 (#1903), so the category is audio_mix, not a second name. The RMS is not benched: #3009 keeps it scalar. docs/rust-port/release-criteria.md describes --category and the categories. Co-Authored-By: Claude Opus 5.5 <[email protected]>
On Apple Silicon, platform.processor() is "arm", so the macOS baseline of #3003 did not name its CPU. The test asks record.py's cpu_name() for the chip from sysctl on macOS. Co-Authored-By: Claude Opus 5.5 <[email protected]>
cpu_name() asks sysctl (machdep.cpu.brand_string) on macOS before it falls back to platform.processor(); Linux still reads /proc/cpuinfo. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two complete record.py runs (5 repeats, 302 pairs each) of ccce18950: - baseline-2026-10-30-linux-x86_64.json: AMD Ryzen 9 5950X, an LXC container on a Proxmox host, pinned to CPU 27 (--cpu 27; no other guest on that core), GCC. - baseline-2026-10-30-macos-arm64.json: Apple M1 Max (MacBook Pro), not pinned, Apple clang. This run came before the cpu_name() fix and wrote "cpu": "arm"; the chip name was filled in from `sysctl -n machdep.cpu.brand_string`. Every other field is as recorded. No Windows baseline: the bench does not link on Windows (#3025). Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=a252febde0ea3cd44bdd3876c9dafceaf3b51a61 secs=451 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run,macos-native:n/a,windows-native:n/a Ci-Attestation: {"at":1793348886,"gate":"rust/all/fmt","host":"linux-x86_64","key":"047b439388daf6652ba2fc7cc19bb6ae2212a7813154b5cff23cf79a5dbb36c0","lane":"lint","parents":["42ebfa137875f873c9b7441580993de96b968d10"],"secs":70,"stamp":"369742f6da5b18008755653c16a6081b","tree":"a252febde0ea3cd44bdd3876c9dafceaf3b51a61","v":1,"via":"run"} Ci-Attestation: {"at":1793348886,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"047b439388daf6652ba2fc7cc19bb6ae2212a7813154b5cff23cf79a5dbb36c0","lane":"lint","parents":["42ebfa137875f873c9b7441580993de96b968d10"],"secs":70,"stamp":"c0b7b0b95311280cb92c1c34767ae7cc","tree":"a252febde0ea3cd44bdd3876c9dafceaf3b51a61","v":1,"via":"run"} Ci-Attestation: {"at":1793348886,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"1d840ac657569631fbd008fb222905f7a8fdd6dd789ef6a4f4a712374e7b2ab7","lane":"rust-test","parents":["42ebfa137875f873c9b7441580993de96b968d10"],"secs":230,"stamp":"631fa3d07c4da50ad0fb7d11825ebda9","tree":"a252febde0ea3cd44bdd3876c9dafceaf3b51a61","v":1,"via":"run"} Ci-Attestation: {"at":1793348886,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"d221d5165c6604f673c08f55b552160b9421c082125417f2eab0ffe090d49c1f","lane":"cross","parents":["42ebfa137875f873c9b7441580993de96b968d10"],"secs":151,"stamp":"ea82370c67c4ac8e926701c5a4a1819a","tree":"a252febde0ea3cd44bdd3876c9dafceaf3b51a61","v":1,"via":"run"} Ci-Attestation: {"at":1793348886,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"d221d5165c6604f673c08f55b552160b9421c082125417f2eab0ffe090d49c1f","lane":"cross","parents":["42ebfa137875f873c9b7441580993de96b968d10"],"secs":151,"stamp":"f048068ada7be4db889b7dd429cc3842","tree":"a252febde0ea3cd44bdd3876c9dafceaf3b51a61","v":1,"via":"run"} Ci-Attestation: {"at":1793348886,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"d221d5165c6604f673c08f55b552160b9421c082125417f2eab0ffe090d49c1f","lane":"cross","parents":["42ebfa137875f873c9b7441580993de96b968d10"],"secs":151,"stamp":"07717457768af8484a418c7f5fdae6b3","tree":"a252febde0ea3cd44bdd3876c9dafceaf3b51a61","v":1,"via":"run"} Ci-Attestation: {"at":1793348886,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"d221d5165c6604f673c08f55b552160b9421c082125417f2eab0ffe090d49c1f","lane":"cross","parents":["42ebfa137875f873c9b7441580993de96b968d10"],"secs":151,"stamp":"0e4493593bb124e8fa0ad4c0e0c0ff99","tree":"a252febde0ea3cd44bdd3876c9dafceaf3b51a61","v":1,"via":"run"} Ci-Attestation: {"at":1793348886,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"26a3e1e83f81c55c8647114a6db1d5beb7e5fb2ab276f284dddf53fa37cdbe19","lane":"tier2-linux","parents":["42ebfa137875f873c9b7441580993de96b968d10"],"secs":408,"stamp":"014d239d86372118c94e144ef3d42d1e","tree":"a252febde0ea3cd44bdd3876c9dafceaf3b51a61","v":1,"via":"run"}
|
Ready for review. CI is green ( Auto-merge is off on purpose: please comment before it merges, in particular on the findings for #3004 to #3006 in the description (no caller of the format conversions in OBS; the decompress gap is not SIMD; |
zackees
left a comment
There was a problem hiding this comment.
Coordinator review: LGTM. RED → GREEN (ci/test_benchmark_record.py 7/7), and every bench checks that both sides give the same output before it times anything. The record.py fix (required categories as a subset, the fingerprint covering all of rust/, --category) repairs a release-criteria step that had been broken on master. Two named machines, 5 runs each. The findings change #3009's priorities; I will update it there. Queuing.
The three decompress conversions called the generic Source/Sink traits per pixel: for i420_to_uyvx that was two u8 reads and two u32 writes per output pixel, each one bounds-checked and copied through a fixed-size array, against a C loop that walks row pointers. Measured 1.5-3.2x the C (#3029's baselines). Source gains bytes(offset, len): the row as a slice, once per row, and the pixel loops index it. RawSource builds the slice from the caller's pointer under the same safety contract as read(). The write side stays offset-addressed, because output rows may overlap each other (#3031), but each pair of adjacent pixels is now one 8-byte store like the C's two adjacent uint32_t stores, in the C's order. Parity is unchanged: obs-media-io's 284 lib tests pass, including format_conversion_parity against the C, the _c_scalar stand-ins and the shim, and decompress_422_one_row (the #3031 overlap fixture). Local format ratios (rust/C, best of two record.py runs on a loaded Ryzen 7 3700X; the untouched compress cases move 25% between runs, so this box cannot demonstrate the 1.10 bound): i420_to_uyvx 1.43 -> 0.93 nv12_to_uyvx 1.29 -> 1.17 uyvy_to_uyvx 1.04 -> 1.35 yuy2_to_uyvx 1.28 -> 1.02
…rust#3111) (obs-rust#3114) The three decompress conversions called the generic Source/Sink traits per pixel: for i420_to_uyvx that was two u8 reads and two u32 writes per output pixel, each one bounds-checked and copied through a fixed-size array, against a C loop that walks row pointers. Measured 1.5-3.2x the C (obs-rust#3029's baselines). Source gains bytes(offset, len): the row as a slice, once per row, and the pixel loops index it. RawSource builds the slice from the caller's pointer under the same safety contract as read(). The write side stays offset-addressed, because output rows may overlap each other (obs-rust#3031), but each pair of adjacent pixels is now one 8-byte store like the C's two adjacent uint32_t stores, in the C's order. Parity is unchanged: obs-media-io's 284 lib tests pass, including format_conversion_parity against the C, the _c_scalar stand-ins and the shim, and decompress_422_one_row (the obs-rust#3031 overlap fixture). Local format ratios (rust/C, best of two record.py runs on a loaded Ryzen 7 3700X; the untouched compress cases move 25% between runs, so this box cannot demonstrate the 1.10 bound): i420_to_uyvx 1.43 -> 0.93 nv12_to_uyvx 1.29 -> 1.17 uyvy_to_uyvx 1.04 -> 1.35 yuy2_to_uyvx 1.28 -> 1.02
Fixes #3003
What and why
#3009 needs before and after numbers for every SIMD kernel. This PR adds the three candidate categories to the paired Rust-vs-C benchmarks and records a baseline on two machines.
record.pydid not run on master. Its inventory check required the bench group prefixes to equal its 14 categories (#142). The port benches added since #1997 bring about 38 more prefixes, so a full run stopped with "incomplete benchmark inventory", and the release-criteria step "Record C/Rust benchmark evidence" could not be done. Its source fingerprint also missed most port crates, among themobs-media-io,obs-audio-controlsandobs-core. Changes:CATEGORIESis the required set; other groups are recorded too.format,volmeterandaudio_mixjoin it.--category(repeatable) runs and requires only the named categories, for the before and after numbers of one kernel.rust/(build directories excluded).cpu_name()names the chip on macOS (sysctl);platform.processor()is onlyarmthere.Benches (
rust/obs-c-oracle/benches/port_comparison/). Before timing, each case checks that both sides give the same result.format.rs: the six format-conversion entry points on 1080p linesizes, each against the C as it ships (SSE2 on x86) and against the same C on the plain-C SSE stand-ins (format/<case>_c_scalar/1080p). Both sides write the same bytes.volmeter.rs:get_sample_peak()andget_true_peak()on one tick (1024 frames). The C kernels arestatic, sooracle/audio_controls.cexports two wrappers;obs-audio-controlsmakes itspeakmodule public (#[doc(hidden)], asobs-media-io's test hooks). The results are bit-identical: the first function-level comparison of the two kernels with the C.audio_output_tick.rs: the output clamp (clamp_audio_output, to [-1, 1] and NaN to 0) is a step of the tick, not an entry point, so it is measured inside oneaudio_tick()with 6 mixes of planar stereo with clipped samples and NaNs. The clamped samples are bit-identical.Differences from the issue text:
audio_mix, notaudiomix: the mix add is already benched asaudio_mix/mix_whole_tickandmix_from_frame_300(rust: Port the audio mix and buffering math in obs-audio.c to obs-core (#1846 unit 10, slice 1) #1903), and the tick joins them.Baselines
docs/rust-port/benchmarks/baseline-2026-10-30-linux-x86_64.jsonand-macos-arm64.json:record.py, 5 complete runs, 302 pairs each, measured on ccce18950 (this branch before the rebase onto ad178c3). Between the two, the fingerprinted trees changed only inrust/tools/linux-validate/(Tier 2 tooling, no.rs,.c,.hor.tomlfile), so the benchmarked sources are the same.--cpu 27) that no other guest uses, GCC.cpu_name()fix and wrote"cpu": "arm"; the chip name was filled in fromsysctl -n machdep.cpu.brand_string. Every other field is as recorded.Rust/C medians (below 1: Rust is faster):
format/uyvx_to_i420format/uyvx_to_nv12format/uyvx_to_i444format/i420_to_uyvxformat/nv12_to_uyvxformat/uyvy_to_uyvxformat/yuy2_to_uyvxvolmeter/sample_peak/1024volmeter/true_peak/1024audio_mix/mix_whole_tickaudio_mix/mix_from_frame_300audio_mix/output_tick/stereo_6_mixesOn macOS both C builds run the stand-ins, so the two C columns are the same; one is shown.
Findings for #3004 to #3006
format-conversion.h, for plugins. The Rust is 4 to 5 times slower than the SSE2 C on the compress side, but the work is not on any OBS path.Source::read/Sink::writeis the likely cost, a cheaper fix than SIMD.decompress_422(media-io: decompress_422() converts twice the row it is given #3031): it convertsmin(in_linesize, out_linesize) / 232-bit words per row, so with linesizes in bytes it reads and writes twice the row (/ 4would be one row). The Rust mirrors it, as the parity test requires. No caller in OBS; the bench sizes its buffers by what both sides touch, as the parity test does.sample_peakis 7 times slower than the C on x86. The[f32; 4]lanes withf32::maxare probably not compiled tomaxps(f32::max's NaN rule); the assembly check of perf: obs-audio-controls: SIMD volume meter peak and true peak #3005 can confirm it.true_peakis equal on x86 and faster on aarch64.RED → GREEN
ci/test_benchmark_record.py: 2 failures, 4 errors on the oldrecord.py: the port groups next to the categories are refused, the SIMD categories are not required, the fingerprint missesobs-media-io, no filter). cd7d1c2 (macOS CPU name: 1 error).soldr cargo bench -p obs-c-oracle --bench port_comparison -- --testpasses on Linux x86_64 (600 benches, 0 failures) and on macOS aarch64.ci/test file, 7 cases, 0.7 s; no Rust test added.Checklist
master🤖 Generated with Claude Code