Commit
perf: Add worker thread pool for blazingly fast audio analysis
Commit details
Commit notes
This commit significantly improves audio analysis performance by:
1. Worker Thread Pool (src/workers/pool.ts): - Creates a pool of worker threads based on available CPU cores - Automatic load balancing across workers - Task queuing when all workers are busy - Graceful shutdown with task completion
2. Dedicated Audio Analysis Worker (src/workers/audio-analysis-worker.ts): - Runs CPU-intensive FFT, spectral analysis, BPM detection in separate threads - Parallel execution of independent analysis tasks within each worker - Complete audio feature extraction without blocking main event loop
3. Increased Queue Concurrency: - Audio analysis queue: 3 -> 8 concurrent workers - Guest sample processing: 2 -> 6 concurrent workers - Reduced job timeouts (analysis is now faster)
4. Integration: - analyzeAudioFromFileWorker() function for worker-based analysis - Automatic fallback to main thread on worker failure - Proper shutdown handling for worker pool
Expected performance improvements: - 3-5x faster throughput on multi-core systems - Main event loop remains responsive during analysis - Better handling of batch uploads from multiple users
Co-authored-by: armin.naimi <[email redacted]>
- Files changed
- 6
- Lines added
- +1,535
- Lines removed
- −54