Skip to content

chore: perf: benchmark the SIMD candidates in record.py (format conversion, volume meter, audio mix) #3003

Closed

Description

@zackees

What

Add benchmark categories for the SIMD candidates to rust/tools/benchmarks/record.py (CATEGORIES, line 20) and paired Rust-vs-C Criterion benches under rust/obs-c-oracle/benches/port_comparison/, then record a baseline:

  • format: rust/obs-media-io/src/format_conversion.rs vs libobs/media-io/format-conversion.c.h (SSE2), e.g. UYVX→I420, NV12/I420 1080p frame.
  • volmeter: rust/obs-audio-controls/src/peak.rs:16 (sample_peak), :28 (true_peak), volmeter.rs:252 (RMS) vs libobs/obs-audio-controls.c.h:303,349,445.
  • audiomix: rust/obs-core/src/audio_mix.rs:178 (mix_into) vs libobs/obs-audio-mix.c.h:47-55; output clamp rust/obs-media-io/src/ffi/audio_output.rs:283 vs libobs/media-io/audio-io.c.h:115.

(The existing conversions category is UTF-8/wide-string conversion, not pixel formats.)

Why

Every other SIMD sub-issue must show a before/after number. No timing exists today (#756: "unmeasured").

Acceptance criteria

  • The three categories are in CATEGORIES, and record.py's entry-count check is updated.
  • A recorded baseline JSON next to docs/rust-port/benchmarks/baseline-2026-10-14.json, with the CPU named and medians and ranges for each case.

Failing-test sketch

record.py's own check ({key.split("/")[0] for key in entries} != CATEGORIES) fails RED once the categories are added without benches; GREEN when the benches exist.

Rules for this work (#756): portable stable Rust only (no std::simd/nightly), a scalar fallback with runtime CPU detection, ISA-specific code only in the crate's src/platform/ (Dylint ban_platform_cfg_outside_boundary). Tier 3 parity is bit-exact unless the C reference itself uses SIMD (docs/rust-port/testing-policy.md:296). RED then GREEN. Every kernel needs a benchmark in rust/tools/benchmarks/record.py first (sub-issue 1 of the meta issue).

Activity

  1. added
    enhancement
    P1
    size:M
    on Oct 30, 2026
  2. zackees commented on Oct 30, 2026

    @zackees
    MemberAuthor

    /ready

    Triage: acceptance criteria and a failing-test sketch are in the body, there are no open dependencies, and the #756 decisions settle the scope. P1: every other sub-issue of #3009 waits on these numbers.

  3. added
    ready
    on Oct 30, 2026
  4. vpacher commented on Oct 30, 2026

    @vpacher
    Member

    Claiming: #3003, the benchmark baseline for the SIMD candidates of #3009.

    Plan (one PR, RED then GREEN):

    1. RED: add format, volmeter and audiomix to CATEGORIES in rust/tools/benchmarks/record.py (and the entry-count check). record.py's inventory check fails, because the benches do not exist yet.

    2. GREEN: paired Rust-vs-C Criterion benches in rust/obs-c-oracle/benches/port_comparison/, with the same inputs on both sides:

      • format: UYVX→I420 and the NV12/I420 conversions at 1080p (rust/obs-media-io/src/format_conversion.rs vs libobs/media-io/format-conversion.c.h, SSE2).
      • volmeter: sample_peak, true_peak and the RMS (rust/obs-audio-controls/src/peak.rs, volmeter.rs vs libobs/obs-audio-controls.c.h) at 1024 frames.
      • audiomix: mix_into (rust/obs-core/src/audio_mix.rs vs libobs/obs-audio-mix.c.h) and the output clamp (rust/obs-media-io/src/ffi/audio_output.rs vs libobs/media-io/audio-io.c.h) at 1024 frames.
    3. Recorded baseline JSON files next to docs/rust-port/benchmarks/baseline-2026-10-14.json, one for each machine, with the CPU named and the medians and ranges of each case:

      • x86_64 Linux: AMD Ryzen on our Proxmox host, in an LXC container with a pinned core (--cpu).
      • aarch64 macOS: Apple Silicon (MacBook Pro).
      • x86_64 Windows (MSVC): a Windows VM on the same Proxmox host.

      perf: obs-media-io: SIMD format conversion (Rust is scalar where the C is SSE2) #3004 asks for one x86_64 and one aarch64 machine. The Windows run shows whether MSVC vectorizes the C differently.

    Draft PR within 48 h.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1enhancementreadysize:M

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions