Skip to content

Comments

Performance: Optimize Mel filterbank application with sparse indices#11

Open
ysdede wants to merge 1 commit intomainfrom
perf/mel-sparse-filterbank-1580082174720780620
Open

Performance: Optimize Mel filterbank application with sparse indices#11
ysdede wants to merge 1 commit intomainfrom
perf/mel-sparse-filterbank-1580082174720780620

Conversation

@ysdede
Copy link
Owner

@ysdede ysdede commented Feb 20, 2026

Performance: Optimize Mel filterbank application with sparse indices

What changed:

  • Precomputed _fbStart and _fbEnd indices for each Mel filter in the MelSpectrogram constructor.
  • Updated computeRawMel to iterate only over the non-zero range of the filterbank matrix.

Why it was needed:

  • Profiling showed that the Mel filterbank application took ~78% of the total processing time.
  • The filterbank matrix is ~98.5% sparse (zeros), meaning most multiplications were wasted.

Impact:

  • ~3.7x speedup for process() calls.
  • 5s audio processing time dropped from ~69ms to ~18.5ms.
  • 10s audio processing time dropped from ~155ms to ~35ms.
  • No regression in accuracy (validated against ONNX reference).

How to verify:

  • Run npm test to verify functional correctness and see benchmark logs.

PR created automatically by Jules for task 1580082174720780620 started by @ysdede

- Precompute start/end indices for non-zero filterbank values.
- Replace dense loop with sparse iteration in computeRawMel.
- ~3.7x speedup (18.5ms vs 69ms for 5s audio).
- Validated against ONNX reference models.
@kiloconnect
Copy link

kiloconnect bot commented Feb 20, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • .jules/bolt.md - Documentation (new file)
  • src/mel.js - Sparse filterbank optimization

Review Notes

The sparse filterbank optimization is well-implemented:

  • Precomputes start/end indices in constructor for each mel bin
  • Uses these indices in computeRawMel to iterate only over non-zero filterbank values
  • This avoids ~98.5% of unnecessary multiplications mentioned in the documentation

No security vulnerabilities, runtime errors, or logic bugs were identified.

Repository owner deleted a comment from google-labs-jules bot Feb 20, 2026
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