Repository navigation
Open
4 / 64 of 6 issues completedLabels
enhancementNew feature or request
Description
Context
Tracks the places where portable SIMD in Rust can make the port measurably faster. It comes from the tree survey on #756 (#756 (comment)) and #756's decisions. Claim an individual sub-issue, not this meta issue. GitHub's native sub-issue list tracks progress.
Rules (from #756)
- Portable, stable Rust only. No
std::simdand no nightly until it stabilizes on the pinned toolchain. - A scalar fallback plus runtime CPU detection. x86_64 (SSE2/AVX2) and aarch64 (NEON).
- ISA-specific code only in the crate's
src/platform/. - Tier 3 parity is bit-exact unless the C reference itself uses SIMD (
docs/rust-port/testing-policy.md:296). - Benchmark first in
rust/tools/benchmarks/record.py(chore: perf: benchmark the SIMD candidates in record.py (format conversion, volume meter, audio mix) #3003). Every kernel PR states before and after numbers on a named machine. - RED then GREEN, one kernel per PR.
Sub-issues, in order
- chore: perf: benchmark the SIMD candidates in record.py (format conversion, volume meter, audio mix) #3003: benchmark the candidates (format conversion, volume meter, audio mix). Blocks all the others. P1
- perf: obs-media-io: SIMD format conversion (Rust is scalar where the C is SSE2) #3004: SIMD format conversion in
rust/obs-media-io. Runs every frame, and the Rust is scalar where the C is SSE2. Highest gain. P1 - perf: obs-audio-controls: SIMD volume meter peak and true peak #3005: volume meter peak and true peak. Every source, every tick; the C is SSE. P2
- perf: audio: verify or force vectorization of mix add and output clamp #3006: check the assembly and force vectorization of mix add and output clamp. Must stay bit-exact. P3
- perf: libobs: vectorize scene audio mixing and source volume multiply when ported #3007: vectorize scene audio mixing and source volume multiply when they are ported. Still C today. P3
- perf: guard: Rust replacements for swresample and swscale must ship with SIMD #3008: guard so that Rust replacements for swresample/swscale ship with SIMD from day one. P3
Considered, not worth it
- Volume meter RMS (
rust/obs-audio-controls/src/volmeter.rs:252): a float reduction against scalar C, so reordering breaks bit-exactness. Only revisit if the policy changes. - Dynamics filters, EQ (
plugins/obs-filters): state carries from one sample to the next, they run only when a user adds them, and they aren't bit-exact. Gain filter and noise-suppress float/s16 conversion: low gain. - Downmix and PulseAudio monitor volume: low gain, per packet.
- Frame, plane and encoder row copies: already memcpy.
- GIF/LZW decode: inherently serial.
- FreeType glyph blit, 3D LUT load: run only on user action.
- Game-capture B5G6R5 copy: already SSE2, C only.
Sub-issues
Collapse Sub-issuesSub-issues
Loading 6 sub-issues
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Type
Projects
- StatusShow more project fieldsTracker
Activity
zackees commentedon Oct 30, 2026
Baseline is in (#3029, which fixes #3003): Rust/C medians on a Ryzen 9 5950X (pinned) and an M1 Max. It changes the order:
sample_peak, is now first. It is 7.2x slower than the SSE C on x86 (1.33x on aarch64) and runs for every source, every audio tick. The likely cause is that[f32; 4]withf32::maxnever becomesmaxps(f32::maxhas its own NaN rule). The fix may be as small as matching the C's comparison, with no intrinsics at all.true_peakis already equal or faster.Source::read/Sink::writeis the cost, not missing SIMD. Rewriting it to work on whole rows is cheaper than SIMD and should come first, if at all. Moving it from P1 to P3.decompress_422(it converts twice the row). No OBS caller.#3007 and #3008 are unchanged.
vpacher commentedon Oct 30, 2026
For information, not a baseline: the same three categories built for x86-64-v3 (AVX2, FMA, BMI2) on both sides, to see what a newer target alone would change. No release builds for it (there is no
target-cpuor-marchin the repo), so this does not change the order above.Setup: master 93b5e64,
record.py --category format --category volmeter --category audio_mix --repeats 3 --cpu 27on the Ryzen 9 5950X of #3029, two runs back to back: v1 with no flags (as shipped), v3 withRUSTFLAGS="-C target-cpu=x86-64-v3"andCFLAGS="-march=x86-64-v3"(both recorded in the JSON). The v1 run matches the #3029 baseline (uyvx_to_i4203.98 against 4.00,sample_peak7.17 against 7.16). With 3 repeats, differences under about 5 % are noise.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/output_tick/stereo_6_mixes(v3/v1 below 1: that side is faster with v3.)
What it shows:
uyvx_to_*): v3 changes nothing for the Rust (1.00). The 4 to 5 times gap is not the instruction set: the per-pixelSource::read/Sink::writekeeps LLVM from vectorizing the loop at any level. Closing it needs a different loop, not a flag.-march=x86-64-v3(GCC); the Rust does not change. A newer-marchis not a free gain for the C side either.sample_peak: v3 makes the Rust 37 % faster but leaves it 4.6 times slower than the C, whose SSE intrinsics do not change. That fits thef32::maxNaN rule as the cause; a newer target alone does not fix it.Windows (MSVC): the bench did not link on Windows (#3025); #3039 fixes that and adds
docs/rust-port/benchmarks/baseline-2026-10-30-windows-x86_64.json(same CPU, MSVC 14.51, at the shipped target; under review, not merged yet). Rust/C there: the compress gap is the same as with GCC (uyvx_to_i4204.16,uyvx_to_nv124.93,uyvx_to_i4443.92); the scalar decompress C is slower with MSVC, so the Rust is equal or faster (nv12_to_uyvx0.95,uyvy_to_uyvx0.53,yuy2_to_uyvx0.50);sample_peakis 3.73,true_peak0.83. On MSVC the_c_scalaroracle is native SSE2 too, so both C columns are SSE2 there.So for the order above: no case for a different release target, #3005's fix belongs in the code (it is slower than the C with every compiler and target measured), and #3004's gap is structural.
perf(bench): Record the SIMD candidates and repair the benchmark reco…