Skip to content

perf(media-io): compress UYVX through direct SIMD row kernels - #3667

Closed
zackees wants to merge 7 commits into
masterfrom
perf/3004-direct-simd-rows
Closed

zackees wants to merge 7 commits into
masterfrom
perf/3004-direct-simd-rows

Conversation

@zackees

@zackees zackees commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Refs #3004

Draft parked: the implementation improves UYVX conversion, but I420 remains 7.4% slower than the C oracle on the final isolated x86 runner. #3004 requires Rust≤C for every conversion on named x86_64 and aarch64 machines, so this PR does not resolve the issue and must not be queued as a completed fix.

The change adds runtime-selected SSE2 (x86_64) and NEON (aarch64) row kernels with the scalar fallback. Each kernel writes directly to borrowed output rows and preserves the C's four-pixel load/store order, including overlapping output rows. A register-only SSE2 packing helper keeps the C instruction sequence because LLVM expanded the equivalent intrinsic expressions into extra shifts/clamps. Its explicit XMM operands use early-clobber constraints, with no memory, stack, or flags effects. Memory accesses remain bounded in the native row kernels.

Measured result

Final x86_64 artifact, commit63f805046, AMD EPYC9V74, three paired record.py repeats, C oracle -O2 -ffp-contract=off -fno-strict-aliasing:

1080p conversion Rust/C aggregate individual paired-ratio range
UYVX→I420 1.0744 1.0714–1.0810
UYVX→NV12 0.9266 0.9245–0.9384
UYVX→I444 0.9506 0.9360–0.9751

The preregistered metric is the existing recorder's median Rust time across three complete repeats divided by median C time across those repeats. Each conversion's aggregate must be ≤1.0; individual paired ranges are reported but not gated. The manual job correctly failed on I420. Evidence: https://github.com/obs-rust/obs-studio/actions/runs/42003496128 (format-benchmark-ubuntu-26.04-42003496128 artifact).

Prior final-head native ARM run at4534c5396 passed all 33 format tests on Apple M1 (Virtual), including printed native/scalar selection. Its Rust/C aggregates were0.0874/0.0863/0.0838 for I420/NV12/I444; the C oracle uses scalar SIMDe stand-ins on ARM, so these do not describe a speedup over tuned production NEON C. Actual Rust medians improved from1.37–1.50ms to0.56–0.69ms (~2–2.7×). NEON/shared code is unchanged in the subsequent x86-only fixes. Evidence: https://github.com/obs-rust/obs-studio/actions/runs/42000633802. The63 final matrix's ARM leg may still be finishing; retain its artifact before resuming work.

An earlier isolated EPYC7763 run at4534c5396 rejected all three x86 aggregates (1.3046/1.3618/1.2705). Exact C intrinsic shaping and register-only packing improved that result, but the remaining I420 gap is stable. Busy local-host results were not used to accept the change. The next investigation would need a new measured optimization, not a weaker bound.

Validation

  • RED0d983c44a: the new forced-kernel parity test fails at its intentional stub, locally and in hosted Fast Gate/macOS.
  • GREEN29a036dfe plus249ac5d88/63f805046: all32 local format cases pass. Every existing random UYVX parity case forces native and scalar paths and compares whole canary-padded outputs with C, C-scalar, safe Rust, and the shim. All original assertions remain.
  • Mutation: disabling native dispatch fails the forced-native assertion.
  • Fresh full pinned lint at63f805046 passed174.5s: CI/Python checks, rustfmt, workspace clippy feature sets, and Dylints. Scoped all-target crate clippy also passes.
  • Test cost: all format cases over25 reduced-parity debug runs, longest0.01035s, peak RSS15.1MiB, no own threads. No new Rust test executable.
  • aarch64-apple-darwin library compilation passes. Native ARM parity and benchmarks passed as above; final required PR CI is still running.
  • clud-review: clean, one primary reviewer with followups through the final register constraints.

Native measurement is an explicit format-benchmark choice in the existing Dispatch workflow. A read-only repository-gated job checks an ancestor baseline SHA, measures base and candidate sequentially in one checkout on ubuntu-26.04/macOS26, runs forced format parity, and always retains machine/compiler metadata, logs and JSON. Tests cover input rejection, actual checkout restoration after probe failure, cache policy, and the exact1.0 threshold. No new workflow file, public C header, existing C test, or public API was changed. There is no user-visible behavior change.

@zackees

zackees commented Nov 7, 2026

Copy link
Copy Markdown
Member Author

Closing under the maintainer-authorized stalled-PR cleanup. The recorded final isolated AMD EPYC 9V74 result is I420 Rust/C = 1.0744 (paired range 1.0714–1.0810), so this change does not meet #3004’s Rust ≤ C acceptance criterion; the benchmark correctly failed. Passing parity and improvements to NV12/I444 do not satisfy that missing requirement. Keep perf/3004-direct-simd-rows and its benchmark artifacts recoverable. #3004 remains open for a measured I420 optimization and named x86_64/aarch64 acceptance; no threshold is weakened.

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.

1 participant