Skip to content

perf(mp3): add bit-exact SIMD kernels that outperform Helix #4055

Closed

Description

@zackees

Context

Phase 4 / G4 of FastLED/license#14. After scalar fixed-point parity, integer SIMD must make minimp3 strictly faster than Helix while remaining bit-exact and optional.

Proposal

Add SSE2 and NEON fixed-point kernels for the dominant polyphase, DCT32, and IMDCT costs, then an ESP32-S3 PIE path. Preserve a scalar opt-out and evaluate Cortex-M4/M7 DSP scheduling without sacrificing precision.

Acceptance criteria

  • Capture RED evidence: performance/dispatch tests show no fixed-point SIMD path and fail the G4 speed targets.
  • Implement SSE2 and NEON int32 paths for polyphase, DCT32, and IMDCT butterflies.
  • Implement compile-time-guarded ESP32-S3 PIE kernels for polyphase and DCT32.
  • Preserve MINIMP3_NO_SIMD and prove scalar fallback behavior.
  • Evaluate Cortex-M4/M7 DSP scheduling, including whether SMLAD can preserve the Q25 precision contract; document and test the result.
  • Require exact PCM equality between every SIMD path and scalar fixed-point across the full corpus and differential fuzzer.
  • Demonstrate at least 1.5x speedup over Helix-scalar on x86-64 and Apple/ARM CI runners and at least 1.3x on ESP32-S3 hardware, with no target slower than scalar fixed-point.
  • Turn the focused RED signal GREEN, pass broader checks, and merge a PR that closes this issue and links Execution plan: vendor minimp3, optimize to Helix parity, SIMD past Helix, delete libhelix_mp3 (phased, gated) license#14.

Decisions

  • Bit-exact equality is blocking because all kernels operate on the same integer representation.
  • Host lanes prove the design before the embedded flagship path.
  • Cortex-M4/M7 DSP work is evidence-driven and may conclude that scalar is the safe path; the conclusion must be documented.
  • This issue depends on G3 and owns G4 only.

Related issues

Activity

  1. zackees commented on Aug 31, 2026

    @zackees
    MemberAuthor

    Acceptance bar set by repo owner (2026-08-31): unit tests and perf tests passing.

    An earlier revision of this comment said the speedup gates were relaxed to informational. That is withdrawn — perf tests gate too.

    For this issue that means:

    • Blocking — implemented for real: the fixed-point SIMD kernels, MINIMP3_NO_SIMD scalar-fallback proof, and exact PCM equality between every SIMD path and scalar fixed-point across the corpus and the differential fuzzer. Bit-exactness is a correctness property and is cheap to verify on host. SIMD stays a hard blocker for chore(mp3): make minimp3 sole backend and remove libhelix #4056.
    • Blocking — perf: ci/codec_cpu/audit.py must be green with the SIMD path measured, and the SIMD path must not be slower than scalar fixed-point on any audited configuration.
    • Out of scope as a test: the >=1.3x on ESP32-S3 hardware target — needs attached hardware, not an automated test. The host >=1.5x over Helix-scalar target is measured and recorded; the enforced host gate is "no target slower than scalar fixed-point" plus the existing 5% trend gate.

    Refs FastLED/license#14.

  2. zackees commented on Sep 1, 2026

    @zackees
    MemberAuthor

    Delivered in #4107 (merged as d68e1e50de). Disposition against the acceptance criteria, including what did not land.

    Done

    • SSE4.1 and NEON int32 kernels for polyphase and DCT-32. Whole-decode speedup 1.10x on x86, bit-identical to scalar sample for sample.
    • MINIMP3_NO_SIMD scalar opt-out proven by a dedicated decoder instantiation, which is also the reference the kernels are compared against.
    • Exact PCM equality across the corpus, plus the differential fuzzer, ASan/UBSan clean.
    • Enforced perf gate: SIMD must not be slower than scalar, running in the CPU audit in release mode (it asserts only in optimised builds — the same kernel measures 0.93x at -O0 and 1.10x at -O3, so -O0 would gate on the compiler rather than the kernel).
    • Cortex-M4/M7 DSP evaluation, concluding scalar stays, with the reasoning recorded in PROVENANCE: SMLAD is a dual 16x16 MAC against a pipeline that is 32-bit mantissas throughout, and SMMUL/SMMLA discard the low half of the product, which is where this decoder's rounding lives.

    Not done, carved out

    Measured results worth keeping

    • The obvious SSE2 implementation is slower than scalar (0.66x standalone, 0.95x end to end): SSE2 has no signed 32x32 -> 64 multiply and the sign-correction emulation costs more than vectorising saves. SSE2-only hardware stays scalar; SSE4.1 dispatches at run time.
    • A branchless 32-bit saturating add was tried and reverted: +6,265 bytes of text (+24%) and 48 bytes of decode stack for ~3% of x86 decode time, justified by an MCU argument that was never measured on an MCU.

    Closing as delivered with the two carve-outs above tracked separately. The bar set on this issue — unit tests and perf tests passing — is met: both mp3 audits and all 32 checks green on the merge.

    Refs FastLED/license#14

  3. moved this from Triage to Done in FastLED Trackeron Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions