Skip to content

build(deps): enable rustfft wasm_simd feature#684

Open
czoli1976 wants to merge 1 commit intoRikorose:mainfrom
czoli1976:ship-upstream/wasm-rustfft-feature
Open

build(deps): enable rustfft wasm_simd feature#684
czoli1976 wants to merge 1 commit intoRikorose:mainfrom
czoli1976:ship-upstream/wasm-rustfft-feature

Conversation

@czoli1976
Copy link
Copy Markdown

Summary

Adds the wasm_simd feature to the rustfft dependency in libDF/Cargo.toml.

Why

wasm_simd is cfg-gated inside rustfft to target_arch = "wasm32" + the feature flag, so enabling it unconditionally is a no-op on every non-wasm target — safe for the cdylib / staticlib / native bin matrix. Native builds are byte-identical.

On wasm32-unknown-unknown with +simd128, this lets rustfft's auto-planner pick FftPlannerWasmSimd (v128 butterflies) instead of falling back to the scalar planner.

Caveats

  • DFN3's specific FFT sizes (480 / 960 mixed-radix) don't materially benefit — tested same-machine back-to-back, RTF stayed at 0.066 on Chromium within noise. The relative share of FFT work in DFN3's per-frame budget is small enough that the speedup gets washed out.
  • Other downstream rustfft consumers (apps with larger or power-of-2 FFT sizes) should benefit more.
  • Wasm size cost is real: the codegen adds ~400 KB compressed.

Opening this anyway because it's bit-exact, zero-risk, and a sensible default for the wasm path. Happy to gate it behind a libDF feature flag (e.g. wasm-simd-fft) instead if you prefer it opt-in.

Test plan

  • Native cargo check --features tract,default-model clean.
  • Wasm32 build with wasm-pack build --target web --release --features wasm succeeds.
  • FNV-1a hash of df_process_frame output bit-equal to baseline across Chromium / WebKit / Firefox.

`wasm_simd` is cfg-gated inside rustfft to wasm32 + the feature flag,
so it's a no-op on non-wasm targets — safe to enable unconditionally
for the cdylib/staticlib/native bin matrix.

On `wasm32-unknown-unknown` with `+simd128`, this lets rustfft's
auto-planner pick `FftPlannerWasmSimd` instead of falling back to
the scalar planner. STFT/iSTFT in DFN3 then use v128 butterflies.

Net effect on DFN3 streaming RTF: within noise (Chromium 0.066 -> 0.066,
both same-machine back-to-back). The FFT sizes used by DFN3 (480 / 960
mixed-radix) don't materially benefit, but the feature is bit-exact,
zero-risk, and helpful to other downstream rustfft consumers (apps
with larger or power-of-2 FFT sizes).

Wasm size cost: +400 KB compressed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant