Repository navigation
Description
Experimental, and mostly unmeasured. Our CI is in the repair shop (see our note on #699), so none of this has been through CI.
We have three fork branches with performance work. We link two of them; the third needs cleanup first. None is a pull request. None has before/after timings. We would like to know which, if any, you want before we open anything.
An illustration of the idea behind the first branch. It is not a result, and it shows no measurements.
1. Dynamics filters in SSE2: perf/27-dynamics-simd
What it changes. It adds plugins/obs-filters/dynamics-simd.h and uses it in the limiter, compressor, expander and noise gate. The envelope follower runs one channel per SSE2 lane, then takes the max across channels, as the scalar loop does. The gain stage uses vector log10 and 10^x polynomial approximations in place of mul_to_db and db_to_mul (libobs/media-io/audio-math.h:31-38, which call log10f and powf). The noise gate is split into three passes: max-abs across channels, the serial gate state machine, then a vector gain multiply. A new cmocka test, test/cmocka/test_dynamics_simd.c, compares each helper with the scalar code it replaced. 4 commits, 7 files, +818/-124.
Hot spots it targets (on master).
plugins/obs-filters/limiter-filter.c:124-151(analyze_envelope) and:153-166(process_compression)plugins/obs-filters/compressor-filter.c:294-321(analyze_envelope),:323-354(analyze_sidechain) and:356-369(process_compression)plugins/obs-filters/expander-filter.c:275-320(analyze_envelope),:322-374(process_sample) and:377-407(process_expansion)plugins/obs-filters/noise-gate-filter.c:110-154(noise_gate_filter_audio)
State. It merges cleanly into current master with no conflicts. It is 865 commits behind, so it needs a rebase before it could be a PR.
Measurement. None.
Things you should know.
- The envelope pass is bit-identical to the scalar code by design, and the test checks that with a memory compare. The gain pass is not bit-identical. The compressor/limiter gain test allows 1e-5 relative error. The expander test allows 2e-2 relative error, and a comment in the test says the measured maximum was about 1.2e-2. So this changes the audio output slightly.
- Mono input stays on the scalar path, because lane packing does not pay for one channel.
- It uses SSE2 intrinsics directly, guarded by
__SSE2__/_M_X64. On arm64 the scalar loops still run. - We expect the user-visible gain to be small. These filters only run when a user adds them, and each is cheap per audio tick. We have not measured that either.
- We can't point you to a passing run of the new test.
2. SIMD tier dispatch crate: perf/54-media-dispatch
What it changes. It adds a small Rust crate, rust/obs-simd (src/dispatch.rs, 271 lines). It detects CPU features at run time and picks a tier: AVX-512BW, AVX2, NEON or scalar. Detection is by feature bits, not CPU model. The result is cached. A thread-local override lets a test force a tier, and it refuses a tier the host lacks. There are unit tests per tier. rust/obs-media-io now depends on the crate. 2 commits, 6 files, +293.
Hot spot it targets. None yet. Nothing calls the crate, and it has no kernel to dispatch to. It is plumbing for later work. We have not picked a first user. The obvious candidate, libobs/media-io/format-conversion.c (for example compress_uyvx_to_i420 at :80), already uses SSE2 intrinsics. Outside the Rust port and its export list, nothing in the tree calls those functions.
State. It does not merge cleanly. Two files conflict: Cargo.lock, and the [dev-dependencies] block of rust/obs-media-io/Cargo.toml. Both look mechanical. rust/README.md changed on both sides but merged without conflict when we checked. Master has changed rust/README.md since, so we have not re-checked that file. It is 596 commits behind.
Measurement. None. There is nothing to measure yet.
Known gaps.
- No SSE4.1 tier, so pre-AVX2 x86 hosts get the scalar tier.
- No VNNI tier.
- AVX-512 is detected as one bit (BW only).
- No NEON dotprod or i8mm detection.
- No documented example of how a kernel calls into a tier.
3. Benchmark harness (bench/harness on our fork, not linked: it needs cleanup before anyone reviews it)
What it changes. It adds bench/harness/ and bench/results-p0/. obs-bench.sh runs OBS headless under Xvfb with software GL. It records 60 seconds of x264 1080p30 from a fixed scene (a color source, a text source and a looping media source). It starts and stops the recording over obs-websocket, samples process CPU every 2 seconds, and writes one JSON file per run. build-t001.sh builds Release trees with ENABLE_RUST_LIBOBS off and on, side by side. make_charts.py draws bar charts. bench/results-p0/ holds nine run JSONs and per-run snapshots of the busiest processes. 14 commits, 35 files, +1073.
Hot spot it targets. None. It measures the whole app, not a function.
State. It only adds files, so it merges cleanly. It is 912 commits behind.
Measurement. These are the only numbers we have, and they do not support any claim.
- They are nine 60-second runs from 11 Oct on one shared x86 server (Intel Skylake-SP), with other jobs running on it.
- They compare the Rust libobs port off against on, at the harness's own base commit. They do not involve either branch above.
- Average process CPU ranged from 103.6% to 484.6% between runs. That spread is far larger than any off-versus-on difference.
- The results README says: "NO MEASURABLE CHANGE (shared-box noise)" and "Do not cite these numbers for speedups." We agree.
Limits.
- The scene has no audio filters, so as written it cannot exercise branch 1. It is not a kernel benchmark either.
- It is Linux and x86 only, and it hard-codes working paths under
/srv. obs-bench.shkills any Xvfb on display:99when it starts, so run it only on a box you own.- It needs a quiet machine. We did not have one.
Related work already on master. #668 added paired Criterion benchmarks of Rust shims against C oracles, a recorder (rust/tools/benchmarks/record.py), and a recorded baseline (docs/rust-port/benchmarks/baseline-2026-10-14.json). Those cover util, graphics and the codec parsers. They do not cover audio filters or media-io. docs/rust-port/release-criteria.md:23-28 also sets a 5% bound on a full-app recording workload. This harness could be one way to produce that number, but we have not tried to line it up with #668.
What is weak
- No before/after timing on real hardware for any of the three.
- No CI run on any of them, and no maintainer review.
- Branch 1 changes audio output slightly, and nobody has listened to it.
- Branch 1 is SSE2 only. It does nothing on arm64 or for mono.
- Branch 2 has no user and an API that will change.
- Branch 3 is Linux-only, noisy, and aimed at the whole app. Its one dataset is unusable.
- All three are hundreds of commits behind master, and branch 2 has two merge conflicts.
What we are asking
- Which of these, if any, would you want upstream? Saying "none of them" is useful.
- Should the harness go first, so that every later perf claim comes with numbers? If so, should it be reworked to build on test: Benchmark Rust hot paths against C oracles #668 and the recording workload in the release criteria, instead of landing as it is?
- For the dynamics filters, is a small numeric difference in the gain stage acceptable (about 1e-5 for the limiter and compressor, up to about 1e-2 for the expander)? Or would you want bit-exact output, with only the envelope pass vectorized?
- For the dispatch crate, do you want it before it has a kernel, or only together with its first one?
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone

Activity
zackees commentedon Oct 25, 2026
/investigate
Triage: thanks for asking before opening PRs. As written this is a request for direction, not yet a task. Whether the project wants it depends on numbers the issue says it doesn't have yet. Missing for Ready:
With those posted here, it can be marked Ready, or escalated if it comes down to a direction choice the measurements don't settle.
zackees commentedon Oct 27, 2026
Triage, second pass, after reading current master. Two of your four questions can be answered from the repo; the other two are priority calls only a maintainer can make.
Settled by the repo
bench/harnessas it stands. test: Benchmark Rust hot paths against C oracles #668 already put a recorder and a baseline on master —rust/tools/benchmarks/record.py(paired Criterion runs, five repeats,--cpupinning) anddocs/rust-port/benchmarks/baseline-2026-10-14.json— and the perf numbers they feed are specified indocs/rust-port/release-criteria.md:46-47(hot paths within 10%, the full-app recording workload within 5%). The recorder'sCATEGORIESset (rust/tools/benchmarks/record.py:20-24: bmem, dstr, vec2–4, crc32, avc, hevc, av1, decl, calldata, proc, signal, conversions) has no audio-filter entry, which matches your observation that audio filters are uncovered. Extending those two files is the shape a reviewer can rerun; a second harness with its own/srvpaths is not.docs/rust-port/testing-policy.md:296is the governing rule: Tier 3 parity is exact bit equality where the C is scalar, and a per-function ULP tolerance is allowed only where the C itself uses SIMD. The four filters are scalar code (plugins/obs-filters/limiter-filter.c.h:118-166on master; the issue's citations are stale only because master renamed.cto.c.hper BUILD.md). So bit-exact is the default: vectorize what stays bit-identical (the envelope pass, which your memory-compare test already pins) and leavemul_to_db/db_to_mul(libobs/media-io/audio-math.h:31-38) scalar. For scale: a 1.2e-2 relative gain error is about 0.10 dB, and 1e-5 is about 0.0001 dB.Missing for the definition of Ready
test/cmocka/test_dynamics_simd.cmust be shown failing against unmodified master (the issue says no passing run can be pointed to, which is the same problem in reverse), and the bit-exact variant above is what it should assert.record.py's categories and post the medians and ranges for one machine with the CPU named.Decision needed: does the project want any of this at all — specifically, is SSE2 work on
plugins/obs-filtersin scope while that directory's port status is what it is, and would you take branch 2 (rust/obs-simd) only together with its first kernel? Both are priority calls, not something the tree answers. If the answer is "harness first", the item above is the whole of it and the other two issues can wait.zackees commentedon Oct 27, 2026
Escalating to the maintainer: both questions in this issue are priority calls about what the project spends time on, not something the tree answers. I researched it — here is what the repo does and does not settle, the options, and my recommendation.
What the repo settles (already posted in the triage above): don't land
bench/harnessas its own thing (#668'srust/tools/benchmarks/record.pyplusdocs/rust-port/benchmarks/baseline-2026-10-14.jsonis the rerunnable shape), and Tier 3 parity for these filters is bit-exact, because the C is scalar (docs/rust-port/testing-policy.md:296).What it does not settle
plugins/obs-filtersin scope at all? Nothing inCONSTITUTION.md,AGENTS.mdordocs/rust-port/release-criteria.mdsays whether performance work on the C tree is welcome while the Rust port is unfinished. The only performance rule there is a bound on the port not being slower (release-criteria.md:46-47: hot paths within 10%, the recording workload within 5%), which does not authorize making the C side faster. The four filters are also not on any hot-path list, and a gain-stage approximation would change audio output by up to ~0.10 dB on the expander.rust/obs-simdbe taken before it has a kernel? A dispatch crate with no caller and an API that its own author says will change is a maintenance cost inrust/, and the repo has no rule for how much unused Rust scaffolding it keeps.Options
record.py'sCATEGORIES) is the cheaper, more reusable piece. If anything lands, it is that: add the four filters to the existing recorder, as its own small task.mul_to_db/db_to_mulscalar), plus a recorded before/after fromrecord.py. That is one issue with a measurable acceptance criterion.Recommendation: A. The port owes a non-regression bound, not a speed-up, and neither the filters nor the dispatch crate is on a path anyone is waiting for. A is also fully reversible: if the maintainer later wants branch 1, the conditions above are already written out in the triage comment.
How to answer: a comment whose first line starts
Decided:(orDecision:) clearshuman-review-neededand resumes the work; removing the label by hand also works. I have swappeddecision-neededforhuman-review-neededso this stops looking like something the coordinator can clear.zackees commentedon Oct 30, 2026
Decided: A — decline the SIMD/dispatch/harness work for now; close this issue as not planned. The door stays open.
Reasons:
docs/rust-port/release-criteria.md:46-47(hot paths within 10 %, recording workload within 5 %). Making the scalar C filters faster is outside what the port is measured on, and none of the four filters is on a hot-path list.docs/rust-port/testing-policy.md:296). The gain-stage approximations (up to 2e-2 relative error on the expander) would not pass it.rust/tools/benchmarks/record.py,docs/rust-port/benchmarks/baseline-2026-10-14.json), and arust/obs-simddispatch crate with no caller and an unstable API is unused scaffolding inrust/.mul_to_db/db_to_mulleft scalar) and a before/after recorded withrecord.pyafter adding the filters to itsCATEGORIES. That issue would be Ready on arrival.Thanks @chriscoveries for asking before opening PRs.
zackees commentedon Oct 30, 2026
Decided: accept SIMD work, on the condition that it is portable. This replaces the earlier decline (#756 (comment)), per the maintainer.
Conditions:
src/platform/boundary, and no nightly-only features (std::simdstays out until it is stable on our pinned toolchain).The first slice can be filed as its own issue and taken as Ready.
zackees commentedon Oct 30, 2026
Decided (amendment to #756 (comment)): two corrections to the conditions.
docs/rust-port/testing-policy.md:296governs: Tier 3 parity is exact bit equality where the C reference is scalar; a per-function ULP tolerance is allowed only where the C uses SIMD. So a vectorized gain stage that differs from scalar C (1e-5 limiter/compressor, up to 1e-2 expander, as reported above) does not pass as-is. Keep the envelope pass (bit-identical by design) or restructure the gain math so it stays exact.CATEGORIESinrust/tools/benchmarks/record.py(test: Benchmark Rust hot paths against C oracles #668) and record medians and ranges on one named machine. The first kernel should be the one likely to move a real number: pixel-format conversion (libobs/media-io/format-conversion.c) is preferred over the dynamics filters, whose per-tick cost is small.A survey of other SIMD candidates in the tree follows in a separate comment.
zackees commentedon Oct 30, 2026
SIMD survey of the tree (read-only; gains are estimates, nothing benchmarked or checked in disassembly).
Today the C reference uses SIMD in six places: format conversion, the volume meter peak, game-capture, the aja/decklink audio repack, rnnoise's kiss_fft and the graphics math headers. No Rust code uses
std::archintrinsics,target_featureorstd::simd.Ranked by likely user-visible gain
rust/obs-media-io/src/format_conversion.rs:106-305(Clibobs/media-io/format-conversion.c.his SSE2)rust/obs-audio-controls/src/peak.rs:16,28(C uses SSE)[f32;4]rust/obs-core/src/audio_mix.rs:178rust/obs-media-io/src/ffi/audio_output.rs:283rust/obs-audio-controls/src/volmeter.rs:252libobs/obs-scene.c.h:1330,1341libobs/obs-source.c.h:4829,4838rust/obs-source/src/audio_input.rs:200-230rust/obs-audio-monitoring/src/pulse_format.rs:316scale_s16roundsplugins/obs-filters)Little or nothing to gain: frame and plane copies (memcpy), GIF/LZW decode (serial), the FreeType blit and LUT load (run only on user action), and the encoders' CPU row copies.
Rust doesn't have these yet: audio resampling (swresample) and software scaling and colorspace conversion (swscale) are still C wrappers around FFmpeg, which is already SIMD. A Rust replacement needs SIMD from day one, or it regresses.
Proposed order:
record.py.Each step is its own issue.
zackees commentedon Oct 30, 2026
Tracking for the SIMD work is now meta issue #3009, with native sub-issues #3003 (benchmarks, which block the rest), #3004 (format conversion), #3005 (volume meter peak and true peak), #3006 (mix add and clamp vectorization), #3007 (scene mix and volume multiply when ported) and #3008 (SIMD guard for any swresample/swscale replacement).
chriscoveries commentedon Oct 31, 2026
Sorry for the long silence here; life got in the way of keeping up. Thank you and vpacher for turning this into #3009 and landing the baseline (#3029) and the first kernels so fast. That's a better plan than ours, so I'm closing this in favour of #3009.
We still have some older perf work that might fit #3009's rules. If any of it is wanted, say which and we'll bring it up to those rules (
record.pynumbers on a named machine, bit-exact where the C is scalar, runtime detection with a scalar fallback, one kernel per PR) before opening anything:If none of these is worth the review time, that's a fine answer too.